HSQLDB does support common table expressions, but the support is broken. CTEs operate more like temprorary tables or views, lasting longer than the duration of the expression. CTEs in earlier queries might take precedence over CTEs with the same name in later queries. Also, if any CTE is recursive, all CTEs must be recursive. If you want to use CTEs with HSQLDB, you'll have to manually modify the dataset to allow it.
Handle HSQLDB specific case insensitive LIKE and bitwise operator support.
# File lib/sequel/adapters/jdbc/hsqldb.rb, line 125 def complex_expression_sql_append(sql, op, args) case op when :ILIKE, :"NOT ILIKE" super(sql, (op == :ILIKE ? :LIKE : :"NOT LIKE"), args.map{|v| SQL::Function.new(:ucase, v)}) when :&, :|, :^ op = BITWISE_METHOD_MAP[op] sql << complex_expression_arg_pairs(args){|a, b| literal(SQL::Function.new(op, a, b))} when :<< sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} * POWER(2, #{literal(b)}))"} when :>> sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} / POWER(2, #{literal(b)}))"} when :% sql << complex_expression_arg_pairs(args){|a, b| "MOD(#{literal(a)}, #{literal(b)})"} when :'B~' sql << BITCOMP_OPEN literal_append(sql, args.at(0)) sql << BITCOMP_CLOSE else super end end
HSQLDB requires recursive CTEs to have column aliases.
# File lib/sequel/adapters/jdbc/hsqldb.rb, line 148 def recursive_cte_requires_column_aliases? true end
HSQLDB does not support IS TRUE.
# File lib/sequel/adapters/jdbc/hsqldb.rb, line 158 def supports_is_true? false end
Use string in hex format for blob data.
# File lib/sequel/adapters/jdbc/hsqldb.rb, line 165 def literal_blob_append(sql, v) sql << BLOB_OPEN << v.unpack(HSTAR).first << APOS end
HSQLDB uses FALSE for false values.
# File lib/sequel/adapters/jdbc/hsqldb.rb, line 170 def literal_false BOOL_FALSE end
HSQLDB handles fractional seconds in timestamps, but not in times
# File lib/sequel/adapters/jdbc/hsqldb.rb, line 175 def literal_sqltime(v) v.strftime(TIME_FORMAT) end
HSQLDB uses TRUE for true values.
# File lib/sequel/adapters/jdbc/hsqldb.rb, line 180 def literal_true BOOL_TRUE end
Use a default FROM table if the dataset does not contain a FROM table.
# File lib/sequel/adapters/jdbc/hsqldb.rb, line 190 def select_from_sql(sql) if @opts[:from] super else sql << DEFAULT_FROM end end
Use WITH RECURSIVE instead of WITH if any of the CTEs is recursive
# File lib/sequel/adapters/jdbc/hsqldb.rb, line 199 def select_with_sql_base opts[:with].any?{|w| w[:recursive]} ? SQL_WITH_RECURSIVE : super end