~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table_proto_write.cc

  • Committer: Stewart Smith
  • Date: 2010-02-19 06:36:37 UTC
  • mto: (1273.19.3 fix_is)
  • mto: This revision was merged to the branch mainline in revision 1309.
  • Revision ID: stewart@flamingspork.com-20100219063637-ios0morjfz5mxejt
correctly set FieldOptions default_null in table proto

This should correct the following problem:

drizzle> create table e ( b int DEFAULT NULL);
Query OK, 0 rows affected (0.01 sec)

drizzle> show fields from e;
+-------+---------+------+---------+-----------------+
| Field | Type    | Null | Default | Default is NULL |
+-------+---------+------+---------+-----------------+
| b     | INTEGER | TRUE |         | FALSE           | 
+-------+---------+------+---------+-----------------+
1 row in set (0 sec)

drizzle> show create table e;
+-------+-----------------------------------------------------------+
| Table | Create Table                                              |
+-------+-----------------------------------------------------------+
| e     | CREATE TABLE `e` (
  `b` int DEFAULT NULL
) ENGINE=InnoDB | 
+-------+-----------------------------------------------------------+
1 row in set (0 sec)


(the default_null in the table proto wasn't set).

Show diffs side-by-side

added added

removed removed

Lines of Context:
247
247
      field_options->set_update_value("NOW()");
248
248
    }
249
249
 
 
250
    if (field_arg->def == NULL  && attribute->constraints().is_nullable())
 
251
    {
 
252
      message::Table::Field::FieldOptions *field_options;
 
253
      field_options= attribute->mutable_options();
 
254
 
 
255
      field_options->set_default_null(true);
 
256
    }
250
257
    if(field_arg->def)
251
258
    {
252
259
      message::Table::Field::FieldOptions *field_options;
253
260
      field_options= attribute->mutable_options();
254
 
 
 
261
 
255
262
      if(field_arg->def->is_null())
256
263
      {
257
264
        field_options->set_default_null(true);