Hi Sujee,

That's what I feared - I didn't think it would be easy to implement this
kind of SQL rewriting correctly via VisitListener. So, unfortunately, I
don't see any better solution right now, short of using regular expressions
to replace the SQL code.

Note that this kind of replacement can be implemented inside of an
ExecuteListener:
-
http://www.jooq.org/doc/latest/manual/sql-building/dsl-context/custom-execute-listeners
- http://www.jooq.org/doc/latest/manual/sql-execution/execute-listeners

That might be a way to make reuse a bit more simple.


2015-05-22 12:50 GMT+02:00 Sujeevan Nagarajah <[email protected]>:

> Hi Lukas,
> I tried both VisitListener and custom query parts. The issue is that
> customised SQL string for a Field is added before its data type definition.
>
> e.g. "product" distkey sortkey varchar null
> It has to be
>        "product" varchar null distkey sortkey
>
> I traced this to CreateTableImpl.accept() where Field object is visited
> and rendered before adding data type and null constraint. It looks like it
> is not possible to make it work without changing the code.
>
> Is there any better solution?
>
> Thank you.
>
> On Thursday, May 21, 2015 at 6:31:12 PM UTC+8, Lukas Eder wrote:
>
>>
>>
>> 2015-05-21 11:03 GMT+02:00 Sujeevan Nagarajah <[email protected]>:
>>
>>> 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:
>>>>
>>>> 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.
>>>
>>
>> Excellent! If you have Liquibase on your stack anyway, that's going to be
>> a good solution for now.
>> Would be very interesting to hear about your experience here on the user
>> group!
>>
>> 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.
>>>
>>
>> Well, I will be very happy to ask you for feedback :)
>>
>> 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.
>

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