JimHagan / wwwsqldesigner

Automatically exported from code.google.com/p/wwwsqldesigner
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

PostgreSQL default not generated in SQL #170

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I can define a default for a column via the GUI, but that default doesn't 
appear in the generated SQL for Postgres syntax (haven't tried others). 

What steps will reproduce the problem?
1. Create a table and define a default on a column. Attached is XML for a table 
with a column called 'stuff' that has a default of 42. Also see screenshot.
2. Generate Postgres SQL

What is the expected output? 

CREATE TABLE "foo" (
"id"  SERIAL ,
"stuff" INTEGER NOT NULL DEFAULT 42,  /* <=== note DEFAULT */
PRIMARY KEY ("id")
);

What do you see instead?

CREATE TABLE "foo" (
"id"  SERIAL ,
"stuff" INTEGER NOT NULL , /* <=== note missing DEFAULT */
PRIMARY KEY ("id")
);

What version of the product are you using? On what operating system?

2.7

Please provide any additional information below.
Thanks for a great tool!

Original issue reported on code.google.com by osvens...@gmail.com on 1 Mar 2013 at 6:59

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by ondrej.zara on 3 Mar 2013 at 6:29

GoogleCodeExporter commented 9 years ago
OK, here's patch that seems to work.

I don't know XSL, but I dove into db/postgresql/output.xsl anyway and came up 
with a one line change that "fixes" the problem. It removes a condition from an 
if statement, so it might break something, but it worked in my test. The patch 
is called maybe.patch to remind you that it may or may not be a good idea.

I can't figure out why the patch works since NULL doesn't seem to be an XPath 
keyword. If you feel like explaining it, I wouldn't mind the education. =) 

Also attached is six_columns.xml which defines a six column table with three 
rows of int, text and bool (default == NULL) and three rows of int, text and 
bool with type-appropriate defaults. I used this to text my XSL change.

Original comment by osvens...@gmail.com on 6 Mar 2013 at 5:58

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the patch!

The postgresql datatype definition is a contributed code; I have basically zero 
experience with PostgreSQL myself.

I am not aware of NULL being some special value in XLST; your patch makes sense 
to me and I am going to commit it.

Original comment by ondrej.zara on 7 Mar 2013 at 12:45

GoogleCodeExporter commented 9 years ago
This issue was closed by revision c8d373dc3642.

Original comment by ondrej.zara on 7 Mar 2013 at 12:47