Module: Sequel::SQLite::DatasetMethods
- Includes:
- Dataset::UnsupportedIntersectExceptAll
- Included in:
- JDBC::SQLite::Dataset, Dataset
- Defined in:
- lib/sequel_core/adapters/shared/sqlite.rb
Overview
Instance methods for datasets that connect to an SQLite database
Instance Method Summary collapse
-
#complex_expression_sql(op, args) ⇒ Object
SQLite does not support pattern matching via regular expressions.
-
#delete(opts = {}) ⇒ Object
SQLite performs a TRUNCATE style DELETE if no filter is specified.
-
#insert(*values) ⇒ Object
Insert the values into the database.
-
#insert_sql(*values) ⇒ Object
Allow inserting of values directly from a dataset.
-
#quoted_identifier(c) ⇒ Object
SQLite uses the nonstandard ‘ (backtick) for quoting identifiers.
Instance Method Details
#complex_expression_sql(op, args) ⇒ Object
SQLite does not support pattern matching via regular expressions. SQLite is case insensitive (depending on pragma), so use LIKE for ILIKE.
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/sequel_core/adapters/shared/sqlite.rb', line 117 def complex_expression_sql(op, args) case op when :~, :'!~', :'~*', :'!~*' raise Error, "SQLite does not support pattern matching via regular expressions" when :LIKE, :'NOT LIKE', :ILIKE, :'NOT ILIKE' # SQLite is case insensitive for ASCII, and non case sensitive for other character sets "#{'NOT ' if [:'NOT LIKE', :'NOT ILIKE'].include?(op)}(#{literal(args.at(0))} LIKE #{literal(args.at(1))})" else super(op, args) end end |
#delete(opts = {}) ⇒ Object
SQLite performs a TRUNCATE style DELETE if no filter is specified. Since we want to always return the count of records, do a specific count in the case of no filter.
132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/sequel_core/adapters/shared/sqlite.rb', line 132 def delete(opts = {}) # check if no filter is specified opts = @opts.merge(opts) unless opts[:where] @db.transaction(opts[:server]) do unfiltered_count = count execute_dui(delete_sql(opts)) unfiltered_count end else execute_dui(delete_sql(opts)) end end |
#insert(*values) ⇒ Object
Insert the values into the database.
147 148 149 |
# File 'lib/sequel_core/adapters/shared/sqlite.rb', line 147 def insert(*values) execute_insert(insert_sql(*values)) end |
#insert_sql(*values) ⇒ Object
Allow inserting of values directly from a dataset.
152 153 154 155 156 157 158 |
# File 'lib/sequel_core/adapters/shared/sqlite.rb', line 152 def insert_sql(*values) if (values.size == 1) && values.first.is_a?(Sequel::Dataset) "INSERT INTO #{source_list(@opts[:from])} #{values.first.sql};" else super(*values) end end |
#quoted_identifier(c) ⇒ Object
SQLite uses the nonstandard ‘ (backtick) for quoting identifiers.
161 162 163 |
# File 'lib/sequel_core/adapters/shared/sqlite.rb', line 161 def quoted_identifier(c) "`#{c}`" end |