mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 06:14:12 +08:00
Check Rails.version instead of ENV
Like that we can have code that works on multiple Rails versions, and we dont need to mix a new method on Kernel. Also, this makes easier to have multiple versions. For instance, before master was 4.2, which is not the case anymore, so on the code we should check versions and not Environment variables
This commit is contained in:
@ -72,7 +72,7 @@ class SqlBuilder
|
||||
#AS reloads this on tests
|
||||
remove_const :FTYPE_MAP if defined? FTYPE_MAP
|
||||
|
||||
if rails_master?
|
||||
if Rails.version >= "4.2.0"
|
||||
FTYPE_MAP = {
|
||||
23 => ActiveRecord::Type::Integer.new,
|
||||
1114 => ActiveRecord::Type::DateTime.new,
|
||||
@ -102,7 +102,7 @@ class SqlBuilder
|
||||
setters.each_with_index do |mapper, index|
|
||||
translated = row[index]
|
||||
if mapper[1] && !translated.nil?
|
||||
if rails_master?
|
||||
if Rails.version >= "4.2.0"
|
||||
translated = mapper[1].type_cast_from_database(translated)
|
||||
else
|
||||
translated = ActiveRecord::ConnectionAdapters::Column.send mapper[1], translated
|
||||
|
Reference in New Issue
Block a user