Class: InsertSelect::Adapters::SqliteAdapter
- Inherits:
-
BaseAdapter
- Object
- BaseAdapter
- InsertSelect::Adapters::SqliteAdapter
- Defined in:
- lib/insert_select/adapters/sqlite_adapter.rb
Instance Attribute Summary
Attributes inherited from BaseAdapter
Instance Method Summary collapse
- #build_sql(builder) ⇒ Object
-
#initialize(table_name, connection) ⇒ SqliteAdapter
constructor
A new instance of SqliteAdapter.
Constructor Details
#initialize(table_name, connection) ⇒ SqliteAdapter
Returns a new instance of SqliteAdapter.
4 5 6 7 |
# File 'lib/insert_select/adapters/sqlite_adapter.rb', line 4 def initialize(table_name, connection) @table_name = table_name @connection = connection end |
Instance Method Details
#build_sql(builder) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/insert_select/adapters/sqlite_adapter.rb', line 9 def build_sql(builder) # have to be done before we call super, because super will make relation immutable if builder.on_duplicate == :skip builder.relation.where!("TRUE") if builder.relation.where_clause.blank? end stmt = super if builder.on_duplicate == :skip stmt << " ON CONFLICT DO NOTHING" end stmt end |