Thanks Ben and Lukas. This is great stuff. Will definitely keep me busy for 
next few days :) My comments below.

On Thursday, May 21, 2015 at 3:24:59 PM UTC+8, Lukas Eder wrote:
>
> Hi Sujee, Ben
>
> 2015-05-21 9:03 GMT+02:00 <[email protected] <javascript:>>:
>
>> Have you considered Liquibase? It provides an abstraction from SQL, with 
>> an escape hatch to write custom scripts. It may be easier to generate a 
>> changelog document from your inferred schema (and unit test it with H2), 
>> injecting custom SQL for a dialect as needed.
>>
>
> I was tempted to mention Liquibase myself, although I'm not sure if it can 
> handle this particular syntax (i.e. a flag that appears after the data 
> type).
>

> Clearly, Liquibase is providing a similar idea of SQL migration as jOOQ 
> does, although Liquibase probably has a richer DDL API right now. This will 
> certainly change as we add support for more DDL features.
>

I use Liquibase in another module in a normal way. I haven't thought about 
your idea which is very clever. However I'm still uncertain how much 
Liquibase offers in terms of Redshift dialect. I'll explore further. 

>  

> On Wednesday, May 20, 2015 at 10:12:23 PM UTC-7, Sujeevan Nagarajah wrote:
>>>
>>> Thank you Lukas. Now I understand the primary use case of jOOQ 
>>> createTable feature. 
>>>
>>> Typical application has a fixed schema or schema that rarely changes. 
>>> Also when there is a change, schema changes applied during application 
>>> start.
>>> But my use case is totally different from it. I'm working on a feature 
>>> where schema of a dataset is detected and corresponding table is created in 
>>> run-time. Since the schema is generated programatically in runtime, I'm 
>>> looking for some kind of Java DSL library like jOOQ createTable. Obviously 
>>> Flyway can be useful here to manage the schema generated by DSL but it 
>>> doesn't help to generate it. What would you recommend for my use-case? An 
>>> idea I have is to do some String manipulation on the table statement result 
>>> generated by jOOQ. 
>>>
>>
> Thank you for these clarifications. That certainly makes sense.
>
> Well probably, there are other databases that have similar flags at the 
> same syntactic location. Also, we still have an open issue to support 
> inline constraints as well in jOOQ 3.7. I think we can look into this for 
> the next release and make this work for you:
> https://github.com/jOOQ/jOOQ/issues/4298 
>

As usual, thanks Lukas for making things happen. This is my most preferred 
solution in the future. I'll be happy to test and provide feedback when you 
decided to implement.

>  

> Right now, I can see these options:
>
> *Doing string manipulation after SQL generation by jOOQ*
>
> This might work using regular expressions, as the injection place would be 
> after a "(column name) (data type)(insert here)," pattern. This certainly 
> doesn't feel very good
>
> *Using VisitListener to transform the SQL*
>
> The standard approach do perform custom SQL transformation directly on the 
> jOOQ AST would be via a VisitListener implementation:
>
> http://www.jooq.org/doc/latest/manual/sql-building/queryparts/custom-sql-transformation
>
> I'm not sure if the possibilities that we currently offer here are 
> sufficient for DDL transformation, though, as that wasn't our primary 
> use-case at the time we added VisitListeners
>
> *Writing your own custom Query implementation*
>
> This might be a good option if you want to support also other 
> vendor-specific flags and options. Via plain SQL and custom QueryParts, you 
> could write your own little DSL for this use-case:
>
> http://www.jooq.org/doc/latest/manual/sql-building/queryparts/custom-queryparts/
>
>
>
> I guess as a workaround, the simplest solution would be to use string 
> manipulation, indeed.
>
> I'll be very happy to help you find other alternatives, though.
>
My preference is more towards jOOQ createTable DSL since it is easy to 
express queries in Java DSL. I'm thinking to try both VisitListener and 
Custom query parts as they look more cleaner than String manipulation. I'll 
try and contact you if I need any help.

>
> 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.

Reply via email to