Module: Sequel::SQLite::DatasetMethods
- Included in:
- Amalgalite::Dataset, DataObjects::SQLite::Dataset, JDBC::SQLite::Dataset, Dataset
- Defined in:
- lib/sequel/adapters/shared/sqlite.rb
Overview
Instance methods for datasets that connect to an SQLite database
Constant Summary collapse
- 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}
Instance Method Summary collapse
-
#complex_expression_sql(op, args) ⇒ Object
SQLite does not support pattern matching via regular expressions.
-
#constant_sql(constant) ⇒ Object
MSSQL doesn’t support the SQL standard CURRENT_DATE or CURRENT_TIME.
-
#delete ⇒ Object
SQLite performs a TRUNCATE style DELETE if no filter is specified.
-
#quoted_identifier(c) ⇒ Object
SQLite uses the nonstandard ‘ (backtick) for quoting identifiers.
-
#supports_intersect_except_all? ⇒ Boolean
SQLite does not support INTERSECT ALL or EXCEPT ALL.
-
#supports_is_true? ⇒ Boolean
SQLite does not support IS TRUE.
-
#supports_timestamp_timezones? ⇒ Boolean
SQLite supports timezones in literal timestamps, since it stores them as text.
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.
244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/sequel/adapters/shared/sqlite.rb', line 244 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 |
#constant_sql(constant) ⇒ Object
MSSQL doesn’t support the SQL standard CURRENT_DATE or CURRENT_TIME
257 258 259 |
# File 'lib/sequel/adapters/shared/sqlite.rb', line 257 def constant_sql(constant) CONSTANT_MAP[constant] || super end |
#delete ⇒ Object
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.
264 265 266 |
# File 'lib/sequel/adapters/shared/sqlite.rb', line 264 def delete @opts[:where] ? super : filter(1=>1).delete end |
#quoted_identifier(c) ⇒ Object
SQLite uses the nonstandard ‘ (backtick) for quoting identifiers.
269 270 271 |
# File 'lib/sequel/adapters/shared/sqlite.rb', line 269 def quoted_identifier(c) "`#{c}`" end |
#supports_intersect_except_all? ⇒ Boolean
SQLite does not support INTERSECT ALL or EXCEPT ALL
274 275 276 |
# File 'lib/sequel/adapters/shared/sqlite.rb', line 274 def supports_intersect_except_all? false end |
#supports_is_true? ⇒ Boolean
SQLite does not support IS TRUE
279 280 281 |
# File 'lib/sequel/adapters/shared/sqlite.rb', line 279 def supports_is_true? false end |
#supports_timestamp_timezones? ⇒ Boolean
SQLite supports timezones in literal timestamps, since it stores them as text.
285 286 287 |
# File 'lib/sequel/adapters/shared/sqlite.rb', line 285 def true end |