Re: allow_null with typecast

2008-05-26 Thread Jeremy Evans

On May 25, 11:00 am, dusty [EMAIL PROTECTED] wrote:
 I have a timestamp field in my model that I want to allow null on, I'm
 not sure how to do this.  Right now I have it with :allow_null = true
 in my set_schema declaration.  However, when I set that attribute to
 nil and save the record, I get

 Sequel::Error: nil/NULL is not allowed for the email_activated_at
 column

 Here is what it looks like in set_schema

 timestamp   :email_activated_at, :allow_null = true

 How do I allow a null value?

 This is what it looks like when I use reflection on that table.

 Sequel::DATABASES.first.schema_for_table(:users)

 [:email_activated_at,
 {:type=:datetime, :numeric_precision=nil, :max_chars=nil, 
 :primary_key=false, :default=nil, :allow_null=false, 
 :db_type=timestamp}]

 I just assumed that I could add that option in the schema declaration,
 but it looks like I can't.

 BTW - I'm using sqlite right now for this.

This was a bug in the SQLite adapter, it was not determining the
allow_null value correctly.  I just pushed a change that fixes this.
By default, columns should accept NULL values unless you use
the :null=false option when adding the column.

Also check the recent commits, as the schema method changed from
schema_for_table(table, schema=nil) to schema(table=nil, opts={}), and
it now can get the schema for all tables in one call.

Jeremy
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sequel-talk group.
To post to this group, send email to sequel-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~--~~~~--~~--~--~---



Re: allow_null with typecast

2008-05-26 Thread dusty

Great, thanks!  I was using sequel a while back and am now starting to
get back into it.  Excited about all these new changes.  Its looking
real good.

-Dusty

On May 26, 11:21 am, Jeremy Evans [EMAIL PROTECTED] wrote:
 On May 25, 11:00 am, dusty [EMAIL PROTECTED] wrote:



  I have a timestamp field in my model that I want to allow null on, I'm
  not sure how to do this.  Right now I have it with :allow_null = true
  in my set_schema declaration.  However, when I set that attribute to
  nil and save the record, I get

  Sequel::Error: nil/NULL is not allowed for the email_activated_at
  column

  Here is what it looks like in set_schema

      timestamp   :email_activated_at, :allow_null = true

  How do I allow a null value?

  This is what it looks like when I use reflection on that table.

  Sequel::DATABASES.first.schema_for_table(:users)

  [:email_activated_at,
  {:type=:datetime, :numeric_precision=nil, :max_chars=nil, 
  :primary_key=false, :default=nil, :allow_null=false, 
  :db_type=timestamp}]

  I just assumed that I could add that option in the schema declaration,
  but it looks like I can't.

  BTW - I'm using sqlite right now for this.

 This was a bug in the SQLite adapter, it was not determining the
 allow_null value correctly.  I just pushed a change that fixes this.
 By default, columns should accept NULL values unless you use
 the :null=false option when adding the column.

 Also check the recent commits, as the schema method changed from
 schema_for_table(table, schema=nil) to schema(table=nil, opts={}), and
 it now can get the schema for all tables in one call.

 Jeremy
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sequel-talk group.
To post to this group, send email to sequel-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~--~~~~--~~--~--~---



Re: allow_null with typecast

2008-05-25 Thread Farrel

On May 25, 8:00 pm, dusty [EMAIL PROTECTED] wrote:
 I have a timestamp field in my model that I want to allow null on, I'm
 not sure how to do this.  Right now I have it with :allow_null = true
 in my set_schema declaration.

Use ':null = true' instead.

Farrel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sequel-talk group.
To post to this group, send email to sequel-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~--~~~~--~~--~--~---