mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
DEV: remove all calls to SqlBuilder use DB.build instead
This is part of the migration to mini_sql, SqlBuilder.new is being deprecated and replaced with DB.build
This commit is contained in:
parent
76707eec1b
commit
cb824a6b33
25 changed files with 338 additions and 372 deletions
|
@ -1,6 +1,9 @@
|
|||
class SqlBuilder
|
||||
|
||||
def initialize(template, klass = nil)
|
||||
|
||||
Discourse.deprecate("SqlBuilder is deprecated and will be removed, please use DB.build instead!")
|
||||
|
||||
@args = {}
|
||||
@sql = template
|
||||
@sections = {}
|
||||
|
@ -75,12 +78,8 @@ class SqlBuilder
|
|||
|
||||
class RailsDateTimeDecoder < PG::SimpleDecoder
|
||||
def decode(string, tuple = nil, field = nil)
|
||||
if Rails.version >= "4.2.0"
|
||||
@caster ||= ActiveRecord::Type::DateTime.new
|
||||
@caster.cast(string)
|
||||
else
|
||||
ActiveRecord::ConnectionAdapters::Column.string_to_time string
|
||||
end
|
||||
@caster ||= ActiveRecord::Type::DateTime.new
|
||||
@caster.cast(string)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -118,9 +117,3 @@ class SqlBuilder
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
class ActiveRecord::Base
|
||||
def self.sql_builder(template)
|
||||
SqlBuilder.new(template, self)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue