Class | Sequel::JDBC::Derby::Dataset |
In: |
lib/sequel/adapters/jdbc/derby.rb
|
Parent: | JDBC::Dataset |
PAREN_CLOSE | = | Dataset::PAREN_CLOSE |
PAREN_OPEN | = | Dataset::PAREN_OPEN |
OFFSET | = | Dataset::OFFSET |
CAST_STRING_OPEN | = | "RTRIM(".freeze |
BITCOMP_OPEN | = | "((0 - ".freeze |
BITCOMP_CLOSE | = | ") - 1)".freeze |
BLOB_OPEN | = | "CAST(X'".freeze |
BLOB_CLOSE | = | "' AS BLOB)".freeze |
HSTAR | = | "H*".freeze |
TIME_FORMAT | = | "'%H:%M:%S'".freeze |
DEFAULT_FROM | = | " FROM sysibm.sysdummy1".freeze |
ROWS | = | " ROWS".freeze |
FETCH_FIRST | = | " FETCH FIRST ".freeze |
ROWS_ONLY | = | " ROWS ONLY".freeze |
BOOL_TRUE | = | '(1 = 1)'.freeze |
BOOL_FALSE | = | '(1 = 0)'.freeze |
SELECT_CLAUSE_METHODS | = | clause_methods(:select, %w'select distinct columns from join where group having compounds order limit lock') |
Derby doesn‘t support an expression between CASE and WHEN, so emulate it by using an equality statement for all of the conditions.
# File lib/sequel/adapters/jdbc/derby.rb, line 166 166: def case_expression_sql_append(sql, ce) 167: if ce.expression? 168: e = ce.expression 169: case_expression_sql_append(sql, ::Sequel::SQL::CaseExpression.new(ce.conditions.map{|c, r| [::Sequel::SQL::BooleanExpression.new('=''=', e, c), r]}, ce.default)) 170: else 171: super 172: end 173: end
If the type is String, trim the extra spaces since CHAR is used instead of varchar. This can cause problems if you are casting a char/varchar to a string and the ending whitespace is important.
# File lib/sequel/adapters/jdbc/derby.rb, line 178 178: def cast_sql_append(sql, expr, type) 179: if type == String 180: sql << CAST_STRING_OPEN 181: super 182: sql << PAREN_CLOSE 183: else 184: super 185: end 186: end
Handle Derby specific LIKE, extract, and some bitwise compliment support.
# File lib/sequel/adapters/jdbc/derby.rb, line 189 189: def complex_expression_sql_append(sql, op, args) 190: case op 191: when :ILIKE 192: super(sql, :LIKE, [SQL::Function.new(:upper, args.at(0)), SQL::Function.new(:upper, args.at(1))]) 193: when "NOT ILIKE""NOT ILIKE" 194: super(sql, "NOT LIKE""NOT LIKE", [SQL::Function.new(:upper, args.at(0)), SQL::Function.new(:upper, args.at(1))]) 195: when :% 196: sql << complex_expression_arg_pairs(args){|a, b| "MOD(#{literal(a)}, #{literal(b)})"} 197: when :&, :|, :^, :<<, :>> 198: raise Error, "Derby doesn't support the #{op} operator" 199: when 'B~''B~' 200: sql << BITCOMP_OPEN 201: literal_append(sql, args.at(0)) 202: sql << BITCOMP_CLOSE 203: when :extract 204: sql << args.at(0).to_s << PAREN_OPEN 205: literal_append(sql, args.at(1)) 206: sql << PAREN_CLOSE 207: else 208: super 209: end 210: end