Skip to content

Custom type that returns BigInt or Nextval('xx') if None #4031

Answered by weiznich
rxdiscovery asked this question in Q&A
Discussion options

You must be logged in to vote

ToSql is fundamentally the wrong abstraction for this kind of behavior. It's only responsible for serializing bind data into a format the database understands. You cannot pass any SQL from this trait.

If you want to implement exactly this behavior the right way is to implement a custom query DSL node. That requires usually to implement at least QueryFragment (describes how to translate something to SQL), QueryId describes how to SQL part interacts with caching prepared statements and Expression describes the SQL side type of your DSL node.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rxdiscovery
Comment options

@weiznich
Comment options

Answer selected by rxdiscovery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants