| Module | Sequel::SQLite::DatasetMethods |
| In: |
lib/sequel/adapters/shared/sqlite.rb
|
Instance methods for datasets that connect to an SQLite database
| SELECT_CLAUSE_METHODS | = | Dataset.clause_methods(:select, %w'distinct columns from join where group having compounds order limit') |
| CONSTANT_MAP | = | {:CURRENT_DATE=>"date(CURRENT_TIMESTAMP, 'localtime')".freeze, :CURRENT_TIMESTAMP=>"datetime(CURRENT_TIMESTAMP, 'localtime')".freeze, :CURRENT_TIME=>"time(CURRENT_TIMESTAMP, 'localtime')".freeze} |
SQLite does not support pattern matching via regular expressions. SQLite is case insensitive (depending on pragma), so use LIKE for ILIKE.
# File lib/sequel/adapters/shared/sqlite.rb, line 244
244: def complex_expression_sql(op, args)
245: case op
246: when :~, '!~''!~', '~*''~*', '!~*''!~*'
247: raise Error, "SQLite does not support pattern matching via regular expressions"
248: when :LIKE, 'NOT LIKE''NOT LIKE', :ILIKE, 'NOT ILIKE''NOT ILIKE'
249: # SQLite is case insensitive for ASCII, and non case sensitive for other character sets
250: "#{'NOT ' if [:'NOT LIKE', :'NOT ILIKE'].include?(op)}(#{literal(args.at(0))} LIKE #{literal(args.at(1))})"
251: else
252: super(op, args)
253: end
254: end
SQLite performs a TRUNCATE style DELETE if no filter is specified. Since we want to always return the count of records, add a condition that is always true and then delete.
# File lib/sequel/adapters/shared/sqlite.rb, line 264
264: def delete
265: @opts[:where] ? super : filter(1=>1).delete
266: end
Return an array of strings specifying a query explanation for a SELECT of the current dataset.
# File lib/sequel/adapters/shared/sqlite.rb, line 270
270: def explain
271: db.send(:metadata_dataset).clone(:sql=>"EXPLAIN #{select_sql}").
272: map{|x| "#{x[:addr]}|#{x[:opcode]}|#{(1..5).map{|i| x[:"p#{i}"]}.join('|')}|#{x[:comment]}"}
273: end