Menu

#82 _unsigned_ should be part of type, must not be attribute

V 3.9
open
Core (7)
5
2014-08-13
2008-06-01
No

(A) Druid should include unsigned datatypes in the list of datatypes in the "DataType Selector" screen
(B) While using Druid with MySQL, I've seen that unsigned is listed as one of the field attributes in the "Field Attribs" tab. This should not be included here.

There are three justifications for this.

(1) Signed/unsigned is really part of the datatype of a field.
(2) If unsigned is treated as a field attribute, and if for a particular database (such as MySQL) it appears later in the list of field attributes, then, in the generated SQL script, in the CREATE TABLE statement, the "unsigned" keyword would appear later than earlier, after other keywords such as "not null", "default" etc. In MySQL this generated SQL script does not run. It gives a syntax error, since MySQL expects the "unsigned" keyword to appear before all these other keywords.
(3) Consider a simple foreign key reference, in which the referenced column is declared as "unsigned" in the referenced table. While generating the SQL, Druid intelligently declares the referencing column as having the same data type as the referenced column, which is good. But it fails to declare the referencing column as "unsigned", even though the referenced column is "unsigned". In MySQL 5.0.x, this gives an error, when the generated SQL script is run. The error (1005) is very cryptic, and it took me some time to trace this error to the mismatch w.r.t. the "unsigned" keyword, between the referenced and referencing columns. Ideally, Druid should automatically make the referencing column also as unsigned, when the referenced column is unsigned, just as it copies the rest of the datatype.

Discussion


Log in to post a comment.