Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Treat interval as it's own type instead of string

The problem with treating interval as a string type is that it
doesn't convert the empty string to nil.  Give interval it's own
type, :interval.  Also, makes sure that all cases in
schema_column_type uses case insensitive and optimized regular
expressions.
  • Loading branch information...
commit b5b9f9bd575ea32ab3beece885ea644e7324e29e 1 parent d720ec0
@jeremyevans authored
Showing with 13 additions and 11 deletions.
  1. +1 −1  CHANGELOG
  2. +12 −10 lib/sequel_core/schema/sql.rb
View
2  CHANGELOG
@@ -2,7 +2,7 @@
* More optimization of Model#initialize (jeremyevans)
-* Treat interval as a string type, not an integer type (jeremyevans)
+* Treat interval as it's own type, not an integer type (jeremyevans)
* Allow use of implicitly qualified symbol as argument to Symbol#qualify (:a.qualify(:b__c)=>b.c.a), fixes model associations in different schemas (jeremyevans) (#246)
View
22 lib/sequel_core/schema/sql.rb
@@ -261,25 +261,27 @@ def schema_utility_dataset
# integer, string, date, datetime, boolean, and float.
def schema_column_type(db_type)
case db_type
- when /\Atinyint/
+ when /\Atinyint/io
Sequel.convert_tinyint_to_bool ? :boolean : :integer
- when /\A(character( varying)?|varchar|text|interval)/
+ when /\Ainterval\z/io
+ :interval
+ when /\A(character( varying)?|varchar|text)/io
:string
- when /\A(int(eger)?|bigint|smallint)/
+ when /\A(int(eger)?|bigint|smallint)/io
:integer
- when /\Adate\z/
+ when /\Adate\z/io
:date
- when /\A(datetime|timestamp( with(out)? time zone)?)\z/
+ when /\A(datetime|timestamp( with(out)? time zone)?)\z/io
:datetime
- when /\Atime( with(out)? time zone)?\z/
+ when /\Atime( with(out)? time zone)?\z/io
:time
- when "boolean"
+ when /\Aboolean\z/io
:boolean
- when /\A(real|float|double( precision)?)\z/
+ when /\A(real|float|double( precision)?)\z/io
:float
- when /\A(numeric(\(\d+,\d+\))?|decimal|money)\z/
+ when /\A(numeric(\(\d+,\d+\))?|decimal|money)\z/io
:decimal
- when "bytea"
+ when /\Abytea\z/io
:blob
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.