Oracle already supports named bind arguments, so use directly.
PostgreSQL specific argument mapper used for mapping the named argument hash to a array with numbered arguments. Only used with the pg driver.
Default implementation of the argument mapper to allow native database support for bind variables and prepared statements (as opposed to the emulated ones used by default).
Set the bind arguments based on the hash and call super.
# File lib/sequel/dataset/prepared_statements.rb, line 22 22: def call(bind_vars={}, &block) 23: ds = bind(bind_vars) 24: ds.prepared_sql 25: ds.bind_arguments = ds.map_to_prepared_args(ds.opts[:bind_vars]) 26: ds.run(&block) 27: end
Override the given *_sql method based on the type, and cache the result of the sql.
# File lib/sequel/dataset/prepared_statements.rb, line 31 31: def prepared_sql 32: return @prepared_sql if @prepared_sql 33: @prepared_args ||= [] 34: @prepared_sql = super 35: @opts[:sql] = @prepared_sql 36: @prepared_sql 37: end
Oracle uses a : before the name of the argument for named arguments.
# File lib/sequel/adapters/oracle.rb, line 307 307: def prepared_arg(k) 308: y, type = k.to_s.split("__", 2) 309: prepared_args << [y.to_sym, type] 310: i = prepared_args.length 311: LiteralString.new(":#{i}") 312: end
PostgreSQL most of the time requires type information for each of arguments to a prepared statement. Handle this by allowing the named argument to have a __* suffix, with the * being the type. In the generated SQL, cast the bound argument to that type to elminate ambiguity (and PostgreSQL from raising an exception).
# File lib/sequel/adapters/postgres.rb, line 612 612: def prepared_arg(k) 613: y, type = k.to_s.split("__") 614: if i = prepared_args.index(y) 615: i += 1 616: else 617: prepared_args << y 618: i = prepared_args.length 619: end 620: LiteralString.new("#{prepared_arg_placeholder}#{i}#{"::#{type}" if type}") 621: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.