Module Sequel::SQLite::DatasetMethods
In: lib/sequel/adapters/shared/sqlite.rb

Instance methods for datasets that connect to an SQLite database

Methods

Constants

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}

Public Instance methods

SQLite does not support pattern matching via regular expressions. SQLite is case insensitive (depending on pragma), so use LIKE for ILIKE.

[Source]

     # File lib/sequel/adapters/shared/sqlite.rb, line 292
292:       def complex_expression_sql(op, args)
293:         case op
294:         when :~, '!~''!~', '~*''~*', '!~*''!~*'
295:           raise Error, "SQLite does not support pattern matching via regular expressions"
296:         when :LIKE, 'NOT LIKE''NOT LIKE', :ILIKE, 'NOT ILIKE''NOT ILIKE'
297:           # SQLite is case insensitive for ASCII, and non case sensitive for other character sets
298:           "#{'NOT ' if [:'NOT LIKE', :'NOT ILIKE'].include?(op)}(#{literal(args.at(0))} LIKE #{literal(args.at(1))})"
299:         else
300:           super(op, args)
301:         end
302:       end

MSSQL doesn‘t support the SQL standard CURRENT_DATE or CURRENT_TIME

[Source]

     # File lib/sequel/adapters/shared/sqlite.rb, line 305
305:       def constant_sql(constant)
306:         CONSTANT_MAP[constant] || super
307:       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.

[Source]

     # File lib/sequel/adapters/shared/sqlite.rb, line 312
312:       def delete
313:         @opts[:where] ? super : filter(1=>1).delete
314:       end

Return an array of strings specifying a query explanation for a SELECT of the current dataset.

[Source]

     # File lib/sequel/adapters/shared/sqlite.rb, line 318
318:       def explain
319:         db.send(:metadata_dataset).clone(:sql=>"EXPLAIN #{select_sql}").
320:           map{|x| "#{x[:addr]}|#{x[:opcode]}|#{(1..5).map{|i| x[:"p#{i}"]}.join('|')}|#{x[:comment]}"}
321:       end

HAVING requires GROUP BY on SQLite

[Source]

     # File lib/sequel/adapters/shared/sqlite.rb, line 324
324:       def having(*cond, &block)
325:         raise(InvalidOperation, "Can only specify a HAVING clause on a grouped dataset") unless @opts[:group]
326:         super
327:       end

SQLite uses the nonstandard ` (backtick) for quoting identifiers.

[Source]

     # File lib/sequel/adapters/shared/sqlite.rb, line 330
330:       def quoted_identifier(c)
331:         "`#{c}`"
332:       end

SQLite does not support INTERSECT ALL or EXCEPT ALL

[Source]

     # File lib/sequel/adapters/shared/sqlite.rb, line 335
335:       def supports_intersect_except_all?
336:         false
337:       end

SQLite does not support IS TRUE

[Source]

     # File lib/sequel/adapters/shared/sqlite.rb, line 340
340:       def supports_is_true?
341:         false
342:       end

SQLite does not support multiple columns for the IN/NOT IN operators

[Source]

     # File lib/sequel/adapters/shared/sqlite.rb, line 345
345:       def supports_multiple_column_in?
346:         false
347:       end

SQLite supports timezones in literal timestamps, since it stores them as text.

[Source]

     # File lib/sequel/adapters/shared/sqlite.rb, line 351
351:       def supports_timestamp_timezones?
352:         true
353:       end

[Validate]