Some results of my research:
The solution proposed my mdaems seems correct but not complete. Zeos isn't telling the fields the correct required property, so it must be changed, something in the way you did. In my tests I only put two () more:
Code: Select all
Required := (IsWritable(I) and (IsNullable(I) = ntNoNulls)) and not HasDefaultValue(I);
This do the trick for that problem with some oddities:
- If you add the component to a form, double-click it, right-click the blank field list and select "Add All", they show up with wrong required properties. By the way, if you leave the list empty and access it only in runtime (using FieldByName), the required is filled correctly. It may be because I'm not installing the whole Zeos when changing the source, but only recompiling the ZComponent package. Whatever.
- The HasDefaultValue property, which is filled in TZMySQLDatabaseMetadata.GetColumns, lie when the field type is CHAR, BLOB, TEXT or SET. By the line 1229 of dbc\ZDbcMySqlMetadata.pas you can find the following comment:
// MySQL bizarity 2:
// For CHAR, BLOB, TEXT and SET types, '' either means: default value is '' or: no default value
// There's absolutely no way of telling when using SHOW COLUMNS FROM,
// the correct information can /only/ be discerned by using information_schema.
// TODO: For now, just use '' as default value for these types, but this should really be fixed to use information_schema.
// For ENUM types, '' means: default value is first value in enum set
// For other types, '' means: no default value
Holly mother crap, we're fucked up.
By the way,
mdaems, when I've changed my source, I can post using the following SQL:
Code: Select all
ZQuery1.Append;
ZQuery1.FieldByName('i2').Value := 'dio';
ZQuery1.Post;
Which means I can post without filling i1 neither id, so they were null on the SQL (I think) and the result line in the database showed i1 = 23 and id = 5 (The correct sequence). Remembering that I can only post successfully that way when I don't fill up the field list at the query in design-time, but only access then in runtime, using FieldByName.
Now I think we must follow two paths:
- Do this change in ZAbstractRODataset and deal with the problems it may produce.
- Do the change on posting routines to fix up the problems
mdaems related. (About TIMESTAMP and AutoIncrement Fields).
To be continued!