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_ORDER = %w'distinct columns from join where group having compounds order limit'.freeze
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 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

MSSQL doesn‘t support the SQL standard CURRENT_DATE or CURRENT_TIME

[Source]

     # File lib/sequel/adapters/shared/sqlite.rb, line 257
257:       def constant_sql(constant)
258:         CONSTANT_MAP[constant] || super
259:       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 264
264:       def delete
265:         @opts[:where] ? super : filter(1=>1).delete
266:       end

Insert the values into the database.

[Source]

     # File lib/sequel/adapters/shared/sqlite.rb, line 269
269:       def insert(*values)
270:         execute_insert(insert_sql(*values))
271:       end

Allow inserting of values directly from a dataset.

[Source]

     # File lib/sequel/adapters/shared/sqlite.rb, line 274
274:       def insert_sql(*values)
275:         if (values.size == 1) && values.first.is_a?(Sequel::Dataset)
276:           "#{insert_sql_base}#{source_list(@opts[:from])} #{values.first.sql};"
277:         else
278:           super(*values)
279:         end
280:       end

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

[Source]

     # File lib/sequel/adapters/shared/sqlite.rb, line 283
283:       def quoted_identifier(c)
284:         "`#{c}`"
285:       end

SQLite does not support INTERSECT ALL or EXCEPT ALL

[Source]

     # File lib/sequel/adapters/shared/sqlite.rb, line 288
288:       def supports_intersect_except_all?
289:         false
290:       end

SQLite does not support IS TRUE

[Source]

     # File lib/sequel/adapters/shared/sqlite.rb, line 293
293:       def supports_is_true?
294:         false
295:       end

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

[Source]

     # File lib/sequel/adapters/shared/sqlite.rb, line 299
299:       def supports_timestamp_timezones?
300:         true
301:       end

[Validate]