Class Sequel::JDBC::Derby::Dataset
In: lib/sequel/adapters/jdbc/derby.rb
Parent: JDBC::Dataset

Dataset class for Derby datasets accessed via JDBC.

Methods

Constants

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')

Public Instance methods

Derby doesn‘t support an expression between CASE and WHEN, so emulate it by using an equality statement for all of the conditions.

[Source]

     # File lib/sequel/adapters/jdbc/derby.rb, line 141
141:         def case_expression_sql_append(sql, ce)
142:           if ce.expression?
143:             e = ce.expression
144:             case_expression_sql_append(sql, ::Sequel::SQL::CaseExpression.new(ce.conditions.map{|c, r| [::Sequel::SQL::BooleanExpression.new('=''=', e, c), r]}, ce.default))
145:           else
146:             super
147:           end
148:         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.

[Source]

     # File lib/sequel/adapters/jdbc/derby.rb, line 153
153:         def cast_sql_append(sql, expr, type)
154:           if type == String
155:             sql << CAST_STRING_OPEN
156:             super
157:             sql << PAREN_CLOSE
158:           else
159:             super
160:           end
161:         end

Handle Derby specific LIKE, extract, and some bitwise compliment support.

[Source]

     # File lib/sequel/adapters/jdbc/derby.rb, line 164
164:         def complex_expression_sql_append(sql, op, args)
165:           case op
166:           when :ILIKE
167:             super(sql, :LIKE, [SQL::Function.new(:upper, args.at(0)), SQL::Function.new(:upper, args.at(1))])
168:           when "NOT ILIKE""NOT ILIKE"
169:             super(sql, "NOT LIKE""NOT LIKE", [SQL::Function.new(:upper, args.at(0)), SQL::Function.new(:upper, args.at(1))])
170:           when :&, :|, :^, :<<, :>>
171:             raise Error, "Derby doesn't support the #{op} operator"
172:           when 'B~''B~'
173:             sql << BITCOMP_OPEN
174:             literal_append(sql, args.at(0))
175:             sql << BITCOMP_CLOSE
176:           when :extract
177:             sql << args.at(0).to_s << PAREN_OPEN
178:             literal_append(sql, args.at(1))
179:             sql << PAREN_CLOSE
180:           else
181:             super
182:           end
183:         end

Derby supports GROUP BY ROLLUP (but not CUBE)

[Source]

     # File lib/sequel/adapters/jdbc/derby.rb, line 186
186:         def supports_group_rollup?
187:           true
188:         end

Derby does not support IS TRUE.

[Source]

     # File lib/sequel/adapters/jdbc/derby.rb, line 191
191:         def supports_is_true?
192:           false
193:         end

Derby does not support IN/NOT IN with multiple columns

[Source]

     # File lib/sequel/adapters/jdbc/derby.rb, line 196
196:         def supports_multiple_column_in?
197:           false
198:         end

[Validate]