2014-04-25 19:21 GMT+02:00 Lukas Eder <[email protected]>: > > > > 2014-04-25 13:12 GMT+02:00 Trygve Laugstøl <[email protected]>: > > kl. 21:50:45 UTC+2 torsdag 24. april 2014 skrev Lukas Eder følgende: >>> >>> Hello Trygve >>> >>> 2014-04-22 20:11 GMT+02:00 Trygve Laugstøl <[email protected]>: >>> >>> Hi >>>> >>>> I was wondering if it is possible to select tables and columns in an >>>> easier way than a single regex as described in [1]. >>>> >>>> We have over 150 tables in our schema, and I'd like to select a small >>>> subset of the tables and subset of the columns in the selected tables. >>>> Right now my <includes> line in the pom.xml is 430 characters long and very >>>> hard to maintain. The reason for selecting the columns too is that some of >>>> our tables have many columns and we're expecting non-relevant columns to >>>> change a lot and when JOOQ does selects it touches all the columns. I >>>> really like the record way of doing it so I'd rather just limit the number >>>> of columns available in the record. >>>> >>>> So the question is if there is a better way to write the "includes" >>>> regex, like for example: >>>> >>>> <includePatterns> >>>> <include>my_table.*</include> >>>> <include>my_other_table.(id|from|to)</include> >>>> </includePatterns> >>>> >>> >>> Yes, something like this was requested before. I cannot seem to find the >>> relevant thread in the user group, though. >>> >>> Essentially, these "multi-include" elements are just the same as a more >>> sophisticated regex (don't forget to escape periods. Just in case): >>> >>> my_table\.*|my_other_table\.(id|from|to) >>> >>> >>> I wonder if we should allow for ignoring whitespace and allowing >>> comments in regexes using http://docs.oracle.com/ >>> javase/7/docs/api/java/util/regex/Pattern.html#COMMENTS >>> >>> my_table\.* (?# This is a comment) >>> | my_other_table\.(id|from|to) (?# This is another comment) >>> >>> >> If you can get it to ignore the whitespace it would be easier, but I >> still think a list of <include> elements would be easier to understand. >> > > It might be easier to understand, but then again, several <include> > elements are semantically equivalent to regex unions / pipes, so I'd like > to avoid implementing this - specifically because regexes in the code > generator configuration are ubiquitous. We'd have to adapt all the other > places too, to have a consistent API. > > Allowing for ignorable whitespace and comments seems more efficient and > easier to maintain. >
The COMMENTS flag is now activated for jOOQ 3.4. This will allow for documenting and formatting regular expressions as can be seen in this integration test configuration here: https://github.com/jOOQ/jOOQ/blob/master/jOOQ-test/configuration/org/jooq/configuration/lukas/h2/library.xml <includes>.*</includes> <excludes> T_BOOK_DETAILS # Check if dependent objects (e.g. foreign keys) are not generated | SYSTEM_SEQUENCE.* # who knows where this came from (sample comment) | .*\.COL2 # v_2603 contains some columns that we don't want to generate | COL3 # v_2603 contains some columns that we don't want to generate </excludes> <includeExcludeColumns>true</includeExcludeColumns> <recordVersionFields> REC_VERSION | ASDF_ASDF_ASDF # This should not have any effect </recordVersionFields> <recordTimestampFields> REC_TIMESTAMP | ASDF_ASDF_ASDF # This should not have any effect | ASDF_ASDF_ASDF # This should not have any effect </recordTimestampFields> I hope this will improve the situation for most users. > > >> I tried the my_table\.* syntax, but couldn't get it to work. What's >> missing from the documentation is what the input strings actually look >> like. From what I could understand from my experiments is that the >> unqualified column names (i.e. only "id", not "my_table.id") are in the >> list, not the qualified names. >> > > That's true, this part could again use some improved documentation. I have > created #3204 for this: > https://github.com/jOOQ/jOOQ/issues/3204 > I noticed that I could've given you a head-start with what will be included in the documentation, once #3204 is fixed :-) Essentially, jOOQ's code generator applies regular expressions to either org.jooq.util.Definition.getName() and org.jooq.util.Definition.getQualifiedName(). If either input string matches a regex, then the respective action is taken. Let's consider again the above example: <excludes> T_BOOK_DETAILS # Check if dependent objects (e.g. foreign keys) are not generated | SYSTEM_SEQUENCE.* # who knows where this came from (sample comment) | .*\.COL2 # v_2603 contains some columns that we don't want to generate | COL3 # v_2603 contains some columns that we don't want to generate </excludes> This will exclude all arrays (Oracle), Enums (PostgreSQL), packages (Oracle), routines, sequences, tables, UDTs (Oracle, PostgreSQL) whose reported name or whose reported fully qualified name of the form SCHEMA.TABLE / SCHEMA.TABLE.COLUMN, etc. matches the above expression. E.g. if you have a table called COL3, then it will be excluded. If you have a table called COL2, it will probably be excluded as well, because when it is fully qualified, ".*\.COL2" still matches "SCHEMA.COL2" This flag: <includeExcludeColumns>true</includeExcludeColumns> Just adds table columns to the list of objects that are filtered. So if you have a column called COL2 or COL3, they're both going to be excluded, because COL3 matches the column name (unqualified) and ".*\.COL2" matches the qualified column name "SCHEMA.TABLE.COL2" I hope this clarifies things a bit. Cheers Lukas -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
