stazz / java-sql-generator

A framework to generate syntactically correct SQL statements in a typesafe, easy, and uniform way (without StringBuilders).
49 stars 28 forks source link

Provide construct to create database generated columns #12

Closed eskatos closed 11 years ago

eskatos commented 11 years ago

Hi Stan,

I would like to create table columns with the following definition:

"my_pk_column BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY"

I did not found any way to do so in current version, tell me if I'm wrong.

/Paul

eskatos commented 11 years ago

The SQL snippet shown above would be the standard one.

Here are the PostgreSQL and MySQL ones :

// Standard SQL:
"my_pk_column BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY"

// PostgreSQL:
"my_pk_column BIGSERIAL PRIMARY KEY"

// MySQL
"my_pk_column BIGINT AUTO_INCREMENT PRIMARY KEY"
stazz commented 11 years ago

Hi Paul, Yes, there is no way to do so in current version. I will start working on implementing this right now and will post here when it's done or something weird happens. :)

stazz commented 11 years ago

I've pushed the changes made for this issue. Unfortunately, I am yet unable to upload the new snapshot to Maven repository. Report any problems here if you have them, I will test more and upload snapshot to Maven repository later this week, hopefully.

Edit: Check out DefinitionFactory for new method which accepts auto generation policy for ColumnDefinition. The primary key specification is still done via different way - by applying UniqueConstraint to TableDefinition.

eskatos commented 11 years ago

Stan,

Tested and approved!

We need a release now :-)

stazz commented 11 years ago

Released version 0.3. with auto-generated column support.