dbsrgits / sql-translator

SQL::Translator (SQLFairy)
http://sqlfairy.sourceforge.net/
82 stars 90 forks source link

datetime types are not quoted #105

Open KES777 opened 6 years ago

KES777 commented 6 years ago
DBG>$from_field
SQL::Translator::Schema::Field {
  _ERROR => ,
  comments => [],
  data_type => timestamp with time zone,
  default_value => \'9999-12-31 23:59:59'::timestamp with time zone,
  extra => {},
  is_auto_increment => 0,
  is_nullable => 0,
  is_primary_key => 0,
  name => known_till,
  order => 4,
  size => [
    0,
  ],
  table => SQL::Translator::Schema::Table person,
}

DBG>$to_field
SQL::Translator::Schema::Field {
  _ERROR => ,
  comments => [],
  data_type => timestamp with time zone,
  default_value => 9999-12-31 23:59:59,
  extra => {},
  is_auto_increment => 0,
  is_nullable => 0,
  is_primary_key => 0,
  name => known_till,
  order => 4,
  size => [
    0,
  ],
  sql_data_type => 0,
  table => SQL::Translator::Schema::Table person,
}

generates correct upgrade sql:

ALTER TABLE person ALTER COLUMN known_till SET DEFAULT '9999-12-31 23:59:59'::timestamp with time zone;

and wrong downgrade:

ALTER TABLE person ALTER COLUMN known_till SET DEFAULT 9999-12-31 23:59:59;