This project is archived and is in readonly mode.

#398 ✓resolved
Praveen Devarao

Non-standard SQL generated in column definition for nullable columns in create table DDL (rails 2.1)

Reported by Praveen Devarao | June 12th, 2008 @ 07:21 AM

In migrations create table generates non-standard SQL which breaks functioning of sql standard compliant databases. The create table method

create_table :accounts, :force => true do |t|

t.integer :firm_id

t.integer :credit_limit


generates the sql as below

CREATE TABLE accounts (id ...., firm_id integer DEFAULT NULL NULL, credit_limit integer DEFAULT NULL NULL)

Focussing on 'DEFAULT NULL NULL', the last NULL is not standard SQL syntax compliant and hence will not work for DB2 and Oracle.

This can be tested here

basically compliant sql syntax is 'COLNAME TYPE DEFAULT CONSTRAINTS'. Constraints is category that this falls into. 'NOT NULL' is a valid constraint, 'NULL' is not.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

Referenced by