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

Instance methods for datasets that connect to an SQLite database

Methods

Included Modules

Dataset::UnsupportedIntersectExceptAll

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_core/adapters/shared/sqlite.rb, line 145
145:       def complex_expression_sql(op, args)
146:         case op
147:         when :~, '!~''!~', '~*''~*', '!~*''!~*'
148:           raise Error, "SQLite does not support pattern matching via regular expressions"
149:         when :LIKE, 'NOT LIKE''NOT LIKE', :ILIKE, 'NOT ILIKE''NOT ILIKE'
150:           # SQLite is case insensitive for ASCII, and non case sensitive for other character sets
151:           "#{'NOT ' if [:'NOT LIKE', :'NOT ILIKE'].include?(op)}(#{literal(args.at(0))} LIKE #{literal(args.at(1))})"
152:         else
153:           super(op, args)
154:         end
155:       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_core/adapters/shared/sqlite.rb, line 160
160:       def delete(opts = {})
161:         # check if no filter is specified
162:         opts = @opts.merge(opts)
163:         super(opts[:where] ? opts : opts.merge(:where=>{1=>1}))
164:       end

Insert the values into the database.

[Source]

     # File lib/sequel_core/adapters/shared/sqlite.rb, line 167
167:       def insert(*values)
168:         execute_insert(insert_sql(*values))
169:       end

Allow inserting of values directly from a dataset.

[Source]

     # File lib/sequel_core/adapters/shared/sqlite.rb, line 172
172:       def insert_sql(*values)
173:         if (values.size == 1) && values.first.is_a?(Sequel::Dataset)
174:           "INSERT INTO #{source_list(@opts[:from])} #{values.first.sql};"
175:         else
176:           super(*values)
177:         end
178:       end

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

[Source]

     # File lib/sequel_core/adapters/shared/sqlite.rb, line 181
181:       def quoted_identifier(c)
182:         "`#{c}`"
183:       end

[Validate]