query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
SQL for dropping a trigger from the database. | def drop_trigger_sql(table, name, opts=OPTS)
"DROP TRIGGER#{' IF EXISTS' if opts[:if_exists]} #{name} ON #{quote_schema_table(table)}#{' CASCADE' if opts[:cascade]}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop_trigger(table_name, trigger_name, options = {})\n SchemaMonkey::Middleware::Migration::CreateTrigger.start(connection: self, table_name: table_name, trigger_name: trigger_name, options: options) do |env|\n table_name = env.table_name\n trigger_name = env.trigger_name\n ... | [
"0.8119375",
"0.7688167",
"0.76867425",
"0.7282038",
"0.7202269",
"0.71872044",
"0.71872044",
"0.7185238",
"0.67402",
"0.658491",
"0.65673536",
"0.6561976",
"0.649828",
"0.6490543",
"0.6459425",
"0.6437757",
"0.6430077",
"0.64237756",
"0.6383998",
"0.6349056",
"0.63020337",
... | 0.82029164 | 0 |
SQL for dropping a view from the database. | def drop_view_sql(name, opts=OPTS)
"DROP #{'MATERIALIZED ' if opts[:materialized]}VIEW#{' IF EXISTS' if opts[:if_exists]} #{quote_schema_table(name)}#{' CASCADE' if opts[:cascade]}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop_view(name)\n execute(\"DROP VIEW #{name}\")\n end",
"def drop_view_sql(name, options)\n \"DROP VIEW#{' IF EXISTS' if options[:if_exists]} #{quote_schema_table(name)}#{' CASCADE' if options[:cascade]}\"\n end",
"def drop_view(view_name, options = {})\n SchemaMonkey::Middleware:... | [
"0.8725758",
"0.8525937",
"0.83034474",
"0.8208464",
"0.796217",
"0.7813755",
"0.779644",
"0.72723156",
"0.68422073",
"0.6783589",
"0.6363096",
"0.63456047",
"0.63331085",
"0.62820417",
"0.62791556",
"0.62631696",
"0.6211049",
"0.6098684",
"0.6076997",
"0.6065854",
"0.6051685... | 0.86309105 | 1 |
If opts includes a :schema option, use it, otherwise restrict the filter to only the currently visible schemas. | def filter_schema(ds, opts)
expr = if schema = opts[:schema]
schema.to_s
else
Sequel.function(:any, Sequel.function(:current_schemas, false))
end
ds.where{{pg_namespace[:nspname]=>expr}}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_shema(schema)\n schema.filter{|obj| include?(obj)}\n end",
"def schema_ds_filter(table_name, opts)\n if table_name\n [{:c__table_name=>table_name.to_s}]\n else\n [{:t__table_type=>'BASE TABLE'}]\n end\n end",
"def skip_schema_queries=(_arg0... | [
"0.60258114",
"0.5587685",
"0.53232336",
"0.53136456",
"0.5252506",
"0.5210141",
"0.5191124",
"0.516309",
"0.51339316",
"0.5003855",
"0.49896494",
"0.49556172",
"0.49474233",
"0.4935256",
"0.49325764",
"0.49156702",
"0.48878336",
"0.4864185",
"0.4861228",
"0.48379704",
"0.483... | 0.72058666 | 0 |
Setup datastructures shared by all postgres adapters. | def initialize_postgres_adapter
@primary_keys = {}
@primary_key_sequences = {}
@supported_types = {}
procs = @conversion_procs = CONVERSION_PROCS.dup
procs[1184] = procs[1114] = method(:to_application_timestamp)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_database\n require \"sequel\"\n\n options = {\n :max_connections => 16,\n :pool_timeout => 240\n }\n\n database_config = YAML.load_file(\"#{$intrigue_basedir}/config/database.yml\")\n database_host = database_config[$intrigue_environment][\"host\"] || \"localhost\"\n database_port = database_... | [
"0.6303121",
"0.62652934",
"0.6196027",
"0.60925674",
"0.60923743",
"0.6072901",
"0.5956406",
"0.59346074",
"0.5915412",
"0.58782214",
"0.58357775",
"0.5783705",
"0.5774008",
"0.5756109",
"0.57473207",
"0.574559",
"0.5708784",
"0.5698038",
"0.56972337",
"0.5685741",
"0.566666... | 0.68285835 | 0 |
Backbone of the tables and views support. | def pg_class_relname(type, opts)
ds = metadata_dataset.from(:pg_class).where(:relkind=>type).select(:relname).server(opts[:server]).join(:pg_namespace, :oid=>:relnamespace)
ds = filter_schema(ds, opts)
m = output_identifier_meth
if defined?(yield)
yield(ds)
elsif opts[:qualify]
ds.select_append{pg_namespace[:nspname]}.map{|r| Sequel.qualify(m.call(r[:nspname]).to_s, m.call(r[:relname]).to_s)}
else
ds.map{|r| m.call(r[:relname])}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table\n end",
"def models\r\n\r\n end",
"def table; end",
"def table; end",
"def table; end",
"def table; end",
"def model; end",
"def model; end",
"def model; end",
"def model; end",
"def model; end",
"def model; end",
"def model; end",
"def model; end",
"def model; end",
"def m... | [
"0.63070464",
"0.62012213",
"0.61893415",
"0.61893415",
"0.61893415",
"0.61893415",
"0.6097337",
"0.6097337",
"0.6097337",
"0.6097337",
"0.6097337",
"0.6097337",
"0.6097337",
"0.6097337",
"0.6097337",
"0.6097337",
"0.60805684",
"0.6072884",
"0.6008782",
"0.6000424",
"0.596926... | 0.0 | -1 |
Return an expression the oid for the table expr. Used by the metadata parsing code to disambiguate unqualified tables. | def regclass_oid(expr, opts=OPTS)
if expr.is_a?(String) && !expr.is_a?(LiteralString)
expr = Sequel.identifier(expr)
end
sch, table = schema_and_table(expr)
sch ||= opts[:schema]
if sch
expr = Sequel.qualify(sch, table)
end
expr = if ds = opts[:dataset]
ds.literal(expr)
else
literal(expr)
end
Sequel.cast(expr.to_s,:regclass).cast(:oid)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table\n if @table_expr.is_a?(AliasedExpression)\n @table_expr.expression\n else\n @table_expr\n end\n end",
"def table_alias\n if @table_expr.is_a?(AliasedExpression)\n @table_expr.alias\n end\n end",
"def expanded_identifier\n ... | [
"0.6339249",
"0.6206004",
"0.5620424",
"0.53660464",
"0.5346105",
"0.5278037",
"0.52770036",
"0.52121466",
"0.50888646",
"0.5088609",
"0.50797004",
"0.50403136",
"0.50403136",
"0.502814",
"0.5012339",
"0.49936682",
"0.49752772",
"0.49023044",
"0.48680702",
"0.4855873",
"0.485... | 0.6270272 | 1 |
Remove the cached entries for primary keys and sequences when a table is changed. | def remove_cached_schema(table)
tab = quote_schema_table(table)
Sequel.synchronize do
@primary_keys.delete(tab)
@primary_key_sequences.delete(tab)
end
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_cached_schema(table)\n tab = quote_schema_table(table)\n Sequel.synchronize do\n @primary_keys.delete(tab)\n end\n super\n end",
"def clean\n disable_referential_integrity do\n tables_cache.keys.reverse_each do |table|\n ActiveRecord... | [
"0.71739537",
"0.6630591",
"0.65746415",
"0.6339876",
"0.63392925",
"0.6294856",
"0.62028897",
"0.6157955",
"0.61444277",
"0.60552055",
"0.60023355",
"0.60008526",
"0.5963297",
"0.5955787",
"0.59497863",
"0.5938426",
"0.59146667",
"0.59047925",
"0.5871068",
"0.5853251",
"0.58... | 0.7296072 | 0 |
SQL DDL statement for renaming a table. PostgreSQL doesn't allow you to change a table's schema in a rename table operation, so specifying a new schema in new_name will not have an effect. | def rename_table_sql(name, new_name)
"ALTER TABLE #{quote_schema_table(name)} RENAME TO #{quote_identifier(schema_and_table(new_name).last)}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rename_table_sql(name, new_name)\n \"ALTER TABLE #{quote_schema_table(name)} RENAME TO #{quote_schema_table(new_name)}\"\n end",
"def rename_table_sql(name, new_name)\n \"ALTER TABLE #{quote_schema_table(name)} RENAME TO #{quote_schema_table(new_name)}\"\n end",
"def rename_table_sql(na... | [
"0.83021253",
"0.82999986",
"0.82999986",
"0.7922324",
"0.78168976",
"0.75273216",
"0.7434364",
"0.7324648",
"0.7227108",
"0.71809715",
"0.7058117",
"0.69426525",
"0.675414",
"0.6689098",
"0.657591",
"0.6376583",
"0.6037233",
"0.6037233",
"0.60329074",
"0.60227203",
"0.598793... | 0.82057774 | 3 |
Handle interval and citext types. | def schema_column_type(db_type)
case db_type
when /\Ainterval\z/io
:interval
when /\Acitext\z/io
:string
else
super
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getIntervalType\n\t\t# get the interval type from settings\n\t\t# currently not implemented. It will useful in future\n\t\tintervalType = 'W'\n\t\tintervalType\n\tend",
"def nonregular_type; end",
"def handle_ts\n handle_at\n handle_in\n @time_special = @tokens[@index].get_tag(TimeSpecial).t... | [
"0.5744355",
"0.57287997",
"0.56326085",
"0.5621758",
"0.5467443",
"0.54393935",
"0.5346401",
"0.5315598",
"0.53015447",
"0.52042335",
"0.51975113",
"0.51377654",
"0.5134359",
"0.51323223",
"0.50979125",
"0.50302005",
"0.50287396",
"0.5001532",
"0.49825865",
"0.49769452",
"0.... | 0.60351527 | 0 |
The schema :type entry to use for array types. | def schema_array_type(db_type)
:array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array_type?\n type = self.sexp_type\n @@array_types.include? type\n end",
"def specimen_array_type=(type)\n setSpecimenArrayType(type)\n unless type.nil? then\n copy_container_type_capacity\n end\n type\n end",
"def datatypes\n value.document.fetch(\"#{value.key}... | [
"0.6450744",
"0.6379572",
"0.63508356",
"0.625358",
"0.6250903",
"0.6245001",
"0.6201754",
"0.61653715",
"0.61405534",
"0.6108816",
"0.61036503",
"0.60928565",
"0.60765946",
"0.60398626",
"0.6015898",
"0.5971627",
"0.59705085",
"0.5964192",
"0.5859733",
"0.5846391",
"0.584043... | 0.81926167 | 0 |
The schema :type entry to use for row/composite types. | def schema_composite_type(db_type)
:composite
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schema_composite_type(db_type)\n @row_schema_types[db_type] || super\n end",
"def inheritance_column\n \"type\"\n end",
"def type\n self['type']\n end",
"def type\n self['type']['type']\n end",
"def type ; metadata[:type] ; end",
"def type_schema\n ... | [
"0.7407996",
"0.6968629",
"0.6907057",
"0.67898774",
"0.6775752",
"0.6767818",
"0.6758813",
"0.6750373",
"0.6736719",
"0.67302775",
"0.6687589",
"0.6660528",
"0.66603494",
"0.66603494",
"0.66603494",
"0.6624262",
"0.6578886",
"0.6575831",
"0.65535015",
"0.6541125",
"0.6524185... | 0.7014892 | 1 |
The schema :type entry to use for enum types. | def schema_enum_type(db_type)
:enum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schema_type(column)\n column.type == :enum_set ? :enum : super\n end",
"def type\n self.class.type_enum_map.key(@cred_struct[:type])\n end",
"def enum_types\n @enum_types ||= schemas.map do |namespace, schema|\n schema.enum_types.map do |name, enum_type|\n [... | [
"0.70020103",
"0.67391855",
"0.6676959",
"0.6676959",
"0.65402603",
"0.65355814",
"0.6528048",
"0.6519687",
"0.6457913",
"0.63885754",
"0.6387319",
"0.6386674",
"0.63202965",
"0.6282332",
"0.6236421",
"0.6234482",
"0.62296706",
"0.62296706",
"0.62296706",
"0.61989784",
"0.619... | 0.8054382 | 0 |
The schema :type entry to use for range types. | def schema_range_type(db_type)
:range
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schema_multirange_type(db_type)\n :multirange\n end",
"def index\n @range_types = RangeType.all\n end",
"def schema_column_type(db_type)\n case db_type\n when /\\Ainterval\\z/io\n :interval\n when /\\Acitext\\z/io\n :string\n else\n sup... | [
"0.71249956",
"0.63931143",
"0.63107294",
"0.62629265",
"0.60207546",
"0.60207546",
"0.60207546",
"0.60200715",
"0.601815",
"0.59934384",
"0.59934384",
"0.5989703",
"0.5982694",
"0.5975312",
"0.5952823",
"0.59515506",
"0.59414446",
"0.5932852",
"0.59324676",
"0.5932421",
"0.5... | 0.8037973 | 0 |
The schema :type entry to use for multirange types. | def schema_multirange_type(db_type)
:multirange
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schema_range_type(db_type)\n :range\n end",
"def schema_column_type(db_type)\n case db_type\n when /\\Ainterval\\z/io\n :interval\n when /\\Acitext\\z/io\n :string\n else\n super\n end\n end",
"def type\n self['type']['type... | [
"0.6891105",
"0.6131667",
"0.6009287",
"0.5958005",
"0.5958005",
"0.5958005",
"0.5958005",
"0.5958005",
"0.5939438",
"0.5932011",
"0.59073764",
"0.58985317",
"0.58985317",
"0.58985317",
"0.5897736",
"0.58881843",
"0.583995",
"0.5836035",
"0.58355254",
"0.58355254",
"0.5835525... | 0.808547 | 0 |
The dataset used for parsing table schemas, using the pg_ system catalogs. | def schema_parse_table(table_name, opts)
m = output_identifier_meth(opts[:dataset])
_schema_ds.where_all(Sequel[:pg_class][:oid]=>regclass_oid(table_name, opts)).map do |row|
row[:default] = nil if blank_object?(row[:default])
if row[:base_oid]
row[:domain_oid] = row[:oid]
row[:oid] = row.delete(:base_oid)
row[:db_domain_type] = row[:db_type]
row[:db_type] = row.delete(:db_base_type)
else
row.delete(:base_oid)
row.delete(:db_base_type)
end
db_type = row[:db_type]
row[:type] = if row.delete(:is_array)
schema_array_type(db_type)
else
send(TYPTYPE_METHOD_MAP[row.delete(:typtype)], db_type)
end
identity = row.delete(:attidentity)
if row[:primary_key]
row[:auto_increment] = !!(row[:default] =~ /\A(?:nextval)/i) || identity == 'a' || identity == 'd'
end
# :nocov:
if server_version >= 90600
# :nocov:
case row[:oid]
when 1082
row[:min_value] = MIN_DATE
row[:max_value] = MAX_DATE
when 1184, 1114
if Sequel.datetime_class == Time
row[:min_value] = MIN_TIMESTAMP
row[:max_value] = MAX_TIMESTAMP
end
end
end
[m.call(row.delete(:name)), row]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _schema_ds\n @_schema_ds ||= begin\n ds = metadata_dataset.select{[\n pg_attribute[:attname].as(:name),\n SQL::Cast.new(pg_attribute[:atttypid], :integer).as(:oid),\n SQL::Cast.new(basetype[:oid], :integer).as(:base_oid),\n SQL::Function.new(:... | [
"0.7500667",
"0.6867395",
"0.66640764",
"0.6582821",
"0.6533815",
"0.6410895",
"0.632692",
"0.6290313",
"0.6165314",
"0.6144493",
"0.610729",
"0.610729",
"0.60320973",
"0.59904265",
"0.59676796",
"0.595397",
"0.5949822",
"0.5930337",
"0.5926021",
"0.59037954",
"0.58810246",
... | 0.6407045 | 6 |
Set the transaction isolation level on the given connection | def set_transaction_isolation(conn, opts)
level = opts.fetch(:isolation, transaction_isolation_level)
read_only = opts[:read_only]
deferrable = opts[:deferrable]
if level || !read_only.nil? || !deferrable.nil?
sql = String.new
sql << "SET TRANSACTION"
sql << " ISOLATION LEVEL #{Sequel::Database::TRANSACTION_ISOLATION_LEVELS[level]}" if level
sql << " READ #{read_only ? 'ONLY' : 'WRITE'}" unless read_only.nil?
sql << " #{'NOT ' unless deferrable}DEFERRABLE" unless deferrable.nil?
log_connection_execute(conn, sql)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_transaction_isolation(conn, opts)\n level = opts.fetch(:isolation, transaction_isolation_level)\n if (jdbc_level = JDBC_TRANSACTION_ISOLATION_LEVELS[level]) &&\n conn.getMetaData.supportsTransactionIsolationLevel(jdbc_level)\n _trans(conn)[:original_jdbc_isolation_level] =... | [
"0.78659075",
"0.6963964",
"0.6858327",
"0.6758857",
"0.6758857",
"0.6613616",
"0.657389",
"0.65524185",
"0.62963855",
"0.6283287",
"0.6274031",
"0.6241779",
"0.6174861",
"0.616061",
"0.6112377",
"0.59543675",
"0.58255845",
"0.58255845",
"0.56776065",
"0.56605256",
"0.5651041... | 0.7724414 | 1 |
Turns an array of argument specifiers into an SQL fragment used for function arguments. See create_function_sql. | def sql_function_args(args)
"(#{Array(args).map{|a| Array(a).reverse.join(' ')}.join(', ')})"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def function_sql(f)\n args = f.args\n \"#{f.f}#{args.empty? ? '()' : literal(args)}\"\n end",
"def irregular_function_sql(f)\n \"#{f.f}(#{literal(f.arg1)} #{f.joiner} #{literal(f.arg2)})\"\n end",
"def compose_sql_array(ary)\n statement, *values = ary\n if values.first.is_a?(Hash... | [
"0.68161327",
"0.6770824",
"0.6261491",
"0.6212632",
"0.6161116",
"0.59570205",
"0.58529675",
"0.58524",
"0.5774345",
"0.5739209",
"0.5678828",
"0.56407475",
"0.5639164",
"0.5581457",
"0.55652213",
"0.5481259",
"0.5450736",
"0.5443238",
"0.5410283",
"0.53626436",
"0.5294864",... | 0.7663649 | 0 |
PostgreSQL can combine multiple alter table ops into a single query. | def supports_combining_alter_table_ops?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_alter_table(name, ops)\n alter_table_sql_list(name, ops).each{|sql| execute_ddl(sql)}\n end",
"def alter_table_sql_list(table, operations)\n operations.map{|op| alter_table_sql(table, op)}\n end",
"def alter_table_sql_list(table, operations)\n operations.map{|op| alter_table_sq... | [
"0.7256814",
"0.68517065",
"0.68125564",
"0.68125564",
"0.67696595",
"0.67665815",
"0.6752053",
"0.67360526",
"0.67310065",
"0.6724511",
"0.669938",
"0.66552204",
"0.6649486",
"0.6588922",
"0.6582951",
"0.6451879",
"0.64394355",
"0.62767357",
"0.60828197",
"0.5993038",
"0.598... | 0.69321823 | 1 |
PostgreSQL supports CREATE OR REPLACE VIEW. | def supports_create_or_replace_view?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_or_replace_view(name, source)\n source = source.sql if source.is_a?(Dataset)\n execute(\"CREATE OR REPLACE VIEW #{name} AS #{source}\")\n end",
"def create_or_replace_view(name, source, options = OPTS)\n if supports_create_or_replace_view?\n options = options.merge(:replace=>t... | [
"0.78645104",
"0.74009097",
"0.7034088",
"0.6799619",
"0.65479636",
"0.650351",
"0.642942",
"0.6428404",
"0.6259404",
"0.6029196",
"0.59640574",
"0.57344437",
"0.5711872",
"0.56566465",
"0.5653659",
"0.56536067",
"0.55815",
"0.54361945",
"0.5410468",
"0.5246351",
"0.52235186"... | 0.71346927 | 2 |
Handle bigserial type if :serial option is present | def type_literal_generic_bignum_symbol(column)
column[:serial] ? :bigserial : super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def supports_serial?\n true\n end",
"def type_literal_generic_bignum(column)\n column[:serial] ? :bigserial : super\n end",
"def type_literal_generic_integer(column)\n column[:serial] ? :serial : super\n end",
"def type_literal_generic_integer(column)\n column[:... | [
"0.68647045",
"0.6242564",
"0.5943363",
"0.5943363",
"0.57919806",
"0.5643944",
"0.5643944",
"0.5393611",
"0.5393611",
"0.5379735",
"0.5183374",
"0.5166281",
"0.512758",
"0.506078",
"0.506078",
"0.50425655",
"0.5034772",
"0.49538374",
"0.49437237",
"0.4926396",
"0.4922839",
... | 0.63120544 | 1 |
PostgreSQL uses the bytea data type for blobs | def type_literal_generic_file(column)
:bytea
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def typecast_value_blob(value)\n value.is_a?(Sequel::SQL::Blob) ? value : Sequel::SQL::Blob.new(value)\n end",
"def type_literal_generic_file(column)\n :blob\n end",
"def blob(s)\n if s.is_a?(SQL::Blob)\n s\n else\n SQL::Blob.new(s)\n end\n end",
"d... | [
"0.748311",
"0.7277911",
"0.6994736",
"0.68574053",
"0.6844959",
"0.6844959",
"0.6809552",
"0.6809552",
"0.6809552",
"0.6809552",
"0.6809552",
"0.6809552",
"0.674962",
"0.66967905",
"0.66562515",
"0.64659435",
"0.6404109",
"0.62737864",
"0.6272902",
"0.6261824",
"0.621018",
... | 0.734235 | 1 |
Handle serial type if :serial option is present | def type_literal_generic_integer(column)
column[:serial] ? :serial : super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def supports_serial?\n true\n end",
"def serial?\n @serial\n end",
"def serial?\n @serial\n end",
"def serial\n fetch('device.serial')\n end",
"def set_serial\n @serial = Serial.find(params[:id])\n end",
"def set_serial\n @serial = Serial.find(... | [
"0.73630124",
"0.66959614",
"0.66959614",
"0.6484796",
"0.61889386",
"0.6171069",
"0.6171069",
"0.5970394",
"0.59641844",
"0.59641844",
"0.5879537",
"0.58395797",
"0.58285207",
"0.57895595",
"0.5720503",
"0.54991263",
"0.5484193",
"0.54618275",
"0.54382974",
"0.5431286",
"0.5... | 0.5012591 | 48 |
PostgreSQL prefers the text datatype. If a fixed size is requested, the char type is used. If the text type is specifically disallowed or there is a size specified, use the varchar type. Otherwise use the text type. | def type_literal_generic_string(column)
if column[:text]
:text
elsif column[:fixed]
"char(#{column[:size]||default_string_column_size})"
elsif column[:text] == false || column[:size]
"varchar(#{column[:size]||default_string_column_size})"
else
:text
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type_literal_generic_string(column)\n if column[:text]\n uses_clob_for_text? ? :clob : :text\n elsif column[:fixed]\n \"char(#{column[:size]||default_string_column_size})\"\n else\n \"varchar(#{column[:size]||default_string_column_size})\"\n end\n end",
"def revert... | [
"0.7334014",
"0.70625246",
"0.69362247",
"0.6559399",
"0.65411496",
"0.65359974",
"0.6518442",
"0.6473457",
"0.64247924",
"0.637079",
"0.63639545",
"0.6286142",
"0.62203",
"0.6183551",
"0.6152284",
"0.5986913",
"0.59777796",
"0.5955377",
"0.58920866",
"0.58748233",
"0.5829819... | 0.76549566 | 0 |
PostgreSQL 9.4+ supports views with check option. | def view_with_check_option_support
# :nocov:
:local if server_version >= 90400
# :nocov:
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def supports_views_with_check_option?\n !!view_with_check_option_support\n end",
"def get_views\n connect_db.fetch(\"SELECT RDB$RELATION_NAME, RDB$VIEW_SOURCE FROM RDB$RELATIONS WHERE RDB$VIEW_BLR IS NOT NULL AND (RDB$SYSTEM_FLAG IS NULL OR RDB$SYSTEM_FLAG = 0)\")\n end",
"def supports_materialized... | [
"0.67245424",
"0.6375552",
"0.63630784",
"0.6352705",
"0.6345518",
"0.6326178",
"0.6318707",
"0.6247733",
"0.6198591",
"0.610404",
"0.60873914",
"0.60536164",
"0.6031846",
"0.6029833",
"0.597804",
"0.5947009",
"0.5936955",
"0.5927375",
"0.58991086",
"0.58800215",
"0.5850445",... | 0.49060613 | 100 |
Return the results of an EXPLAIN ANALYZE query as a string | def analyze
explain(:analyze=>true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def explain(opts=OPTS)\n with_sql((opts[:analyze] ? 'EXPLAIN ANALYZE ' : 'EXPLAIN ') + select_sql).map(:'QUERY PLAN').join(\"\\r\\n\")\n end",
"def explain(arel, binds = [])\n sql = \"EXPLAIN #{to_sql(arel, binds)}\"\n ExplainPrettyPrinter.new.pp(exec_query(sql, 'EXPLAIN', binds))\n... | [
"0.6823953",
"0.6274661",
"0.6253358",
"0.610667",
"0.59947056",
"0.5803804",
"0.5746523",
"0.57279754",
"0.5630922",
"0.54320306",
"0.54110736",
"0.53897107",
"0.5338646",
"0.53190017",
"0.5312021",
"0.5312021",
"0.52763075",
"0.5218137",
"0.5196163",
"0.5192691",
"0.5188185... | 0.65946364 | 1 |
Handle converting the ruby xor operator (^) into the PostgreSQL xor operator (), and use the ILIKE and NOT ILIKE operators. | def complex_expression_sql_append(sql, op, args)
case op
when :^
j = ' # '
c = false
args.each do |a|
sql << j if c
literal_append(sql, a)
c ||= true
end
when :ILIKE, :'NOT ILIKE'
sql << '('
literal_append(sql, args[0])
sql << ' ' << op.to_s << ' '
literal_append(sql, args[1])
sql << ')'
else
super
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ^(p0) end",
"def ^(p0) end",
"def ^(p0) end",
"def ^(p0) end",
"def ^(p0) end",
"def xor(*args)\n args.inject(self, :^)\n end",
"def xor_c\n end",
"def bit_xor\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 52 )\n return_value ... | [
"0.63956505",
"0.63956505",
"0.63956505",
"0.63956505",
"0.63956505",
"0.6362097",
"0.6235052",
"0.6224138",
"0.6133541",
"0.60772306",
"0.60698295",
"0.60334694",
"0.6024499",
"0.600814",
"0.5951814",
"0.5949114",
"0.5923611",
"0.5897365",
"0.586451",
"0.58494306",
"0.582095... | 0.5858377 | 19 |
Disables automatic use of INSERT ... RETURNING. You can still use returning manually to force the use of RETURNING when inserting. This is designed for cases where INSERT RETURNING cannot be used, such as when you are using partitioning with trigger functions or conditional rules, or when you are using a PostgreSQL version less than 8.2, or a PostgreSQL derivative that does not support returning. Note that when this method is used, insert will not return the primary key of the inserted row, you will have to get the primary key of the inserted row before inserting via nextval, or after inserting via currval or lastval (making sure to use the same database connection for currval or lastval). | def disable_insert_returning
clone(:disable_insert_returning=>true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(*values)\n if @opts[:returning]\n # Already know which columns to return, let the standard code handle it\n super\n elsif @opts[:sql] || @opts[:disable_insert_returning]\n # Raw SQL used or RETURNING disabled, just use the default behavior\n # and return... | [
"0.7477058",
"0.74615633",
"0.67061794",
"0.67061794",
"0.6439445",
"0.6295529",
"0.6289652",
"0.6255195",
"0.61770976",
"0.61770976",
"0.60041326",
"0.5992589",
"0.591023",
"0.5897336",
"0.58321005",
"0.5752475",
"0.5752475",
"0.5746446",
"0.57223964",
"0.5720864",
"0.568285... | 0.7500883 | 0 |
Always return false when using VALUES | def empty?
return false if @opts[:values]
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value?(value) true end",
"def single_value?\n return false\n end",
"def value?(value); end",
"def value?(value); end",
"def can_have_value?\n return false\n end",
"def must_have_value?\n return false\n end",
"def has_value?\n false\n end",
"def value_valid?\n return tr... | [
"0.6974655",
"0.68590385",
"0.6858408",
"0.6858408",
"0.68491626",
"0.6778682",
"0.67233634",
"0.66635484",
"0.6622797",
"0.6554162",
"0.6541767",
"0.6498042",
"0.64633584",
"0.6462696",
"0.64158624",
"0.6398311",
"0.6377883",
"0.6355189",
"0.63148046",
"0.6297409",
"0.628743... | 0.64082706 | 15 |
Return the results of an EXPLAIN query as a string | def explain(opts=OPTS)
with_sql((opts[:analyze] ? 'EXPLAIN ANALYZE ' : 'EXPLAIN ') + select_sql).map(:'QUERY PLAN').join("\r\n")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def explain(arel, binds = [])\n sql = \"EXPLAIN #{to_sql(arel, binds)}\"\n ExplainPrettyPrinter.new.pp(exec_query(sql, 'EXPLAIN', binds))\n end",
"def explain(arel, binds = [])\n sql = \"EXPLAIN #{to_sql(arel, binds)}\"\n exec_query(sql, 'EXPLAIN', binds)\n end",... | [
"0.62896997",
"0.61405456",
"0.6137911",
"0.61045426",
"0.5910226",
"0.5868275",
"0.58225495",
"0.5781028",
"0.5762791",
"0.5762791",
"0.5680385",
"0.55741733",
"0.55477244",
"0.55167836",
"0.54632753",
"0.54311174",
"0.5333425",
"0.53226453",
"0.53095716",
"0.52411693",
"0.5... | 0.68310505 | 0 |
Return a cloned dataset which will use FOR SHARE to lock returned rows. | def for_share
lock_style(:share)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fresh_dataset\n @dataset.clone\n end",
"def sync\n cached_dataset(:_sync) do\n clone(:async=>false)\n end\n end",
"def clone\n\t\t\tCData.new self\n\t\tend",
"def clone_with(data)\n clone = self.clone\n clone.instance_variable_set(:@data, data)\n clone\n... | [
"0.70513123",
"0.664276",
"0.65596753",
"0.6316082",
"0.623675",
"0.62346923",
"0.6225567",
"0.6163938",
"0.6147911",
"0.6105954",
"0.60953987",
"0.60944986",
"0.60446715",
"0.60446715",
"0.601016",
"0.59808946",
"0.5952227",
"0.59251606",
"0.591666",
"0.5907834",
"0.5882934"... | 0.0 | -1 |
Run a full text search on PostgreSQL. By default, searching for the inclusion of any of the terms in any of the cols. Options: :headline :: Append a expression to the selected columns aliased to headline that contains an extract of the matched text. :language :: The language to use for the search (default: 'simple') :plain :: Whether a plain search should be used (default: false). In this case, terms should be a single string, and it will do a search where cols contains all of the words in terms. This ignores search operators in terms. :phrase :: Similar to :plain, but also adding an ILIKE filter to ensure that returned rows also include the exact phrase used. :rank :: Set to true to order by the rank, so that closer matches are returned first. :to_tsquery :: Can be set to :plain or :phrase to specify the function to use to convert the terms to a ts_query. :tsquery :: Specifies the terms argument is already a valid SQL expression returning a tsquery, and can be used directly in the query. :tsvector :: Specifies the cols argument is already a valid SQL expression returning a tsvector, and can be used directly in the query. | def full_text_search(cols, terms, opts = OPTS)
lang = Sequel.cast(opts[:language] || 'simple', :regconfig)
unless opts[:tsvector]
phrase_cols = full_text_string_join(cols)
cols = Sequel.function(:to_tsvector, lang, phrase_cols)
end
unless opts[:tsquery]
phrase_terms = terms.is_a?(Array) ? terms.join(' | ') : terms
query_func = case to_tsquery = opts[:to_tsquery]
when :phrase, :plain
:"#{to_tsquery}to_tsquery"
else
(opts[:phrase] || opts[:plain]) ? :plainto_tsquery : :to_tsquery
end
terms = Sequel.function(query_func, lang, phrase_terms)
end
ds = where(Sequel.lit(["", " @@ ", ""], cols, terms))
if opts[:phrase]
raise Error, "can't use :phrase with either :tsvector or :tsquery arguments to full_text_search together" if opts[:tsvector] || opts[:tsquery]
ds = ds.grep(phrase_cols, "%#{escape_like(phrase_terms)}%", :case_insensitive=>true)
end
if opts[:rank]
ds = ds.reverse{ts_rank_cd(cols, terms)}
end
if opts[:headline]
ds = ds.select_append{ts_headline(lang, phrase_cols, terms).as(:headline)}
end
ds
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_text_search(cols, terms, opts = {})\n filter(\"CONTAINS (#{literal(cols)}, #{literal(terms)})\")\n end",
"def fulltext_search(search_string)\n\n # Strip out !, (), &, and |, because these are search vector control characters\n # Remove extra spaces\n search_string = search_str... | [
"0.8264869",
"0.6610546",
"0.6217637",
"0.60479075",
"0.6005078",
"0.59993774",
"0.59954834",
"0.5823916",
"0.5810335",
"0.57882714",
"0.57503736",
"0.57445025",
"0.5727415",
"0.5721591",
"0.5706118",
"0.5620432",
"0.5587604",
"0.55812776",
"0.5575823",
"0.5558891",
"0.555722... | 0.88017637 | 0 |
Insert given values into the database. | def insert(*values)
if @opts[:returning]
# Already know which columns to return, let the standard code handle it
super
elsif @opts[:sql] || @opts[:disable_insert_returning]
# Raw SQL used or RETURNING disabled, just use the default behavior
# and return nil since sequence is not known.
super
nil
else
# Force the use of RETURNING with the primary key value,
# unless it has been disabled.
returning(insert_pk).insert(*values){|r| return r.values.first}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert values\n im = InsertManager.new @engine\n im.insert values\n @engine.connection.insert im.to_sql\n end",
"def insert values\n if $VERBOSE\n warn <<-eowarn\ninsert (#{caller.first}) is deprecated and will be removed in ARel 3.0.0. Please\nswitch to `compile_insert`\n ... | [
"0.8384631",
"0.77768993",
"0.7730328",
"0.74888915",
"0.7317124",
"0.7303931",
"0.72238153",
"0.7149737",
"0.7133511",
"0.6991141",
"0.69711584",
"0.6948114",
"0.69270784",
"0.6870819",
"0.6832507",
"0.6806778",
"0.67923105",
"0.67868817",
"0.67507815",
"0.67170304",
"0.6700... | 0.62298536 | 67 |
Ignore uniqueness/exclusion violations when inserting, using ON CONFLICT DO NOTHING. Exists mostly for compatibility to MySQL's insert_ignore. Example: DB[:table].insert_ignore.insert(a: 1, b: 2) INSERT INTO TABLE (a, b) VALUES (1, 2) ON CONFLICT DO NOTHING | def insert_ignore
insert_conflict
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sql_for_on_duplicate_key_ignore( *args ) # :nodoc:\n arg = args.first\n conflict_target = sql_for_conflict_target( arg ) if arg.is_a?( Hash )\n \" ON CONFLICT #{conflict_target}DO NOTHING\"\n end",
"def sql_for_on_duplicate_key_ignore( table_name, *args ) # :nodoc:\n arg = args.first\n confli... | [
"0.7616945",
"0.75842595",
"0.62032014",
"0.60689807",
"0.5857675",
"0.5805015",
"0.57581186",
"0.57069135",
"0.56307864",
"0.55492955",
"0.5548208",
"0.5485306",
"0.5469368",
"0.5457529",
"0.54266727",
"0.54110026",
"0.53848934",
"0.53830725",
"0.5364832",
"0.53096676",
"0.5... | 0.7311335 | 2 |
Insert a record, returning the record inserted, using RETURNING. Always returns nil without running an INSERT statement if disable_insert_returning is used. If the query runs but returns no values, returns false. | def insert_select(*values)
return unless supports_insert_select?
# Handle case where query does not return a row
server?(:default).with_sql_first(insert_select_sql(*values)) || false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(*values)\n if @opts[:returning]\n # Already know which columns to return, let the standard code handle it\n super\n elsif @opts[:sql] || @opts[:disable_insert_returning]\n # Raw SQL used or RETURNING disabled, just use the default behavior\n # and return... | [
"0.7542973",
"0.7532102",
"0.68789726",
"0.65688646",
"0.65688646",
"0.62109786",
"0.6128794",
"0.612806",
"0.6119359",
"0.6069529",
"0.6069529",
"0.5990838",
"0.597326",
"0.5886588",
"0.5826648",
"0.58002967",
"0.5799923",
"0.5799923",
"0.5799923",
"0.5736858",
"0.573113",
... | 0.6084432 | 9 |
The SQL to use for an insert_select, adds a RETURNING clause to the insert unless the RETURNING clause is already present. | def insert_select_sql(*values)
ds = opts[:returning] ? self : returning
ds.insert_sql(*values)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)\n return super if id_value\n pk = pk_from_insert_sql(sql) unless pk\n select_value(\"#{sql} RETURNING #{quote_column_name(pk)}\")\n end",
"def insert_sql(sql, name = nil, pk = nil, id_value = ... | [
"0.7520621",
"0.7520621",
"0.7286327",
"0.72612214",
"0.7190447",
"0.71479136",
"0.71042174",
"0.70045507",
"0.6908703",
"0.6906702",
"0.68156385",
"0.6802465",
"0.65613794",
"0.65613794",
"0.65486777",
"0.6533989",
"0.6515687",
"0.64841336",
"0.6463996",
"0.6424976",
"0.6369... | 0.7737149 | 2 |
Support SQL::AliasedExpression as expr to setup a USING join with a table alias for the USING columns. | def join_table(type, table, expr=nil, options=OPTS, &block)
if expr.is_a?(SQL::AliasedExpression) && expr.expression.is_a?(Array) && !expr.expression.empty? && expr.expression.all?
options = options.merge(:join_using=>true)
end
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_using_clause_using_sql_append(sql, using_columns)\n if using_columns.is_a?(SQL::AliasedExpression)\n super(sql, using_columns.expression)\n sql << ' AS '\n identifier_append(sql, using_columns.alias)\n else\n super\n end\n end",
"def table_al... | [
"0.7116942",
"0.6341112",
"0.6315534",
"0.61744845",
"0.61428946",
"0.5945142",
"0.5900595",
"0.5848707",
"0.5788944",
"0.5637029",
"0.5637029",
"0.55842906",
"0.5584003",
"0.5542869",
"0.55291176",
"0.5422773",
"0.539866",
"0.53588843",
"0.53473353",
"0.5325972",
"0.53084874... | 0.694539 | 1 |
Locks all tables in the dataset's FROM clause (but not in JOINs) with the specified mode (e.g. 'EXCLUSIVE'). If a block is given, starts a new transaction, locks the table, and yields. If a block is not given, just locks the tables. Note that PostgreSQL will probably raise an error if you lock the table outside of an existing transaction. Returns nil. | def lock(mode, opts=OPTS)
if defined?(yield) # perform locking inside a transaction and yield to block
@db.transaction(opts){lock(mode, opts); yield}
else
sql = 'LOCK TABLE '.dup
source_list_append(sql, @opts[:from])
mode = mode.to_s.upcase.strip
unless LOCK_MODES.include?(mode)
raise Error, "Unsupported lock mode: #{mode}"
end
sql << " IN #{mode} MODE"
@db.execute(sql, opts)
end
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lock(mode, &block)\n sql = LOCK % [source_list(@opts[:from]), mode]\n @db.synchronize do\n if block # perform locking inside a transaction and yield to block\n @db.transaction {@db.execute(sql); yield}\n else\n @db.execute(sql) # lock without a transaction\... | [
"0.80996597",
"0.79946315",
"0.6768143",
"0.6706339",
"0.6692717",
"0.64592165",
"0.63696915",
"0.6278538",
"0.61654204",
"0.6085429",
"0.5980977",
"0.5813835",
"0.5738062",
"0.5736289",
"0.5650982",
"0.5603849",
"0.5572628",
"0.54926866",
"0.5452597",
"0.54325897",
"0.539995... | 0.8043198 | 1 |
Support OVERRIDING USER|SYSTEM VALUE for MERGE INSERT. | def merge_insert(*values, &block)
h = {:type=>:insert, :values=>values}
if override = @opts[:override]
h[:override] = insert_override_sql(String.new)
end
_merge_when(h, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_override_sql(sql)\n case opts[:override]\n when :system\n sql << \" OVERRIDING SYSTEM VALUE\"\n when :user\n sql << \" OVERRIDING USER VALUE\"\n end\n end",
"def user(value)\n merge(grcuser: value.to_s)\n end",
"def user(value)\n ... | [
"0.61191076",
"0.5459569",
"0.5366964",
"0.53619355",
"0.5327483",
"0.52746403",
"0.5234136",
"0.5216786",
"0.5106798",
"0.5106798",
"0.5089168",
"0.5080714",
"0.507201",
"0.5056244",
"0.5054719",
"0.50507313",
"0.49865487",
"0.49532232",
"0.48932272",
"0.48855317",
"0.488461... | 0.0 | -1 |
Use OVERRIDING USER VALUE for INSERT statements, so that identity columns always use the user supplied value, and an error is not raised for identity columns that are GENERATED ALWAYS. | def overriding_system_value
clone(:override=>:system)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pre_insert(sql, name, pk, id_value, sequence_name)\n @iiTable = get_table_name(sql)\n @iiCol = get_autounique_column(@iiTable)\n @iiEnabled = false\n\n if @iiCol != nil\n if query_contains_autounique_col(sql, @iiCol)\n begin\n @connection.do(enable_identity_insert(@iiTable, tru... | [
"0.6686499",
"0.6655386",
"0.6655386",
"0.63866425",
"0.60911673",
"0.6082206",
"0.5972562",
"0.58565605",
"0.58565605",
"0.5833101",
"0.58189833",
"0.5700909",
"0.5526677",
"0.5524249",
"0.5490326",
"0.5410405",
"0.53914815",
"0.53832036",
"0.53686273",
"0.53593254",
"0.5359... | 0.0 | -1 |
Use OVERRIDING USER VALUE for INSERT statements, so that identity columns always use the sequence value instead of the user supplied value. | def overriding_user_value
clone(:override=>:user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_insert(sql, name, pk, id_value, sequence_name)\n if @iiEnabled\n begin\n @connection.do(enable_identity_insert(@iiTable, false))\n rescue Exception => e\n raise ActiveRecordError, \"IDENTITY_INSERT could not be turned off\"\n end\n end\n end",
"def post_insert(sql, na... | [
"0.641532",
"0.641532",
"0.6394933",
"0.6344944",
"0.61432767",
"0.5999143",
"0.5999143",
"0.5999143",
"0.59119934",
"0.5821073",
"0.580872",
"0.5805352",
"0.5773662",
"0.57513803",
"0.57405144",
"0.57136685",
"0.5676146",
"0.5676146",
"0.5662054",
"0.5639374",
"0.56253314",
... | 0.0 | -1 |
PostgreSQL supports using the WITH clause in subqueries if it supports using WITH at all (i.e. on PostgreSQL 8.4+). | def supports_cte_in_subqueries?
supports_cte?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pipe_cte_with!(subquery)\n return self unless subquery.try(:with_values?)\n\n # Add subquery CTE's to the parents query stack. (READ THE SPECIAL NOTE ABOVE!)\n if @scope.with_values?\n @scope.cte.pipe_cte_with!(subquery.cte)\n else\n # Top level has no with values\... | [
"0.65679926",
"0.6192909",
"0.6192909",
"0.58103573",
"0.56718576",
"0.5354886",
"0.53479433",
"0.521933",
"0.5205962",
"0.5173415",
"0.5141739",
"0.4965617",
"0.49448887",
"0.49384052",
"0.49377605",
"0.49164754",
"0.4882845",
"0.4826609",
"0.47812265",
"0.4751949",
"0.47344... | 0.516487 | 10 |
DISTINCT ON is a PostgreSQL extension | def supports_distinct_on?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distinct\n with_opts(:distinct=>true)\n end",
"def merge_distinct_on\n return if other.distinct_on_values.blank?\n relation.distinct_on_values += other.distinct_on_values\n end",
"def query_all(args = {})\n query(args.merge(select: \"DISTINCT #{model.table_name... | [
"0.67026377",
"0.64181125",
"0.6210453",
"0.6127123",
"0.6123081",
"0.58022785",
"0.57420564",
"0.5667245",
"0.5633823",
"0.556171",
"0.556171",
"0.5497905",
"0.5404564",
"0.54010093",
"0.5378762",
"0.53698623",
"0.53211236",
"0.5319152",
"0.5245783",
"0.52205163",
"0.5183464... | 0.737513 | 0 |
PostgreSQL 9.5+ supports GROUP CUBE | def supports_group_cube?
server_version >= 90500
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_cube\n raise Error, \"GROUP BY CUBE not supported on #{db.database_type}\" unless supports_group_cube?\n clone(:group_options=>:cube)\n end",
"def group_by\n end",
"def group_by\n\n end",
"def grouping\n @grouping ||= :clustered\n end",
"def sql_inventory_groups\n \"WITH... | [
"0.68689656",
"0.5705153",
"0.56319845",
"0.5569599",
"0.5513369",
"0.5487213",
"0.54530466",
"0.54303354",
"0.53565013",
"0.5345835",
"0.5262092",
"0.5247198",
"0.52150446",
"0.52146983",
"0.52088636",
"0.5204516",
"0.5204516",
"0.520431",
"0.5196585",
"0.51422703",
"0.51301... | 0.49682838 | 34 |
PostgreSQL 9.5+ supports GROUP ROLLUP | def supports_group_rollup?
server_version >= 90500
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_rollup\n raise Error, \"GROUP BY ROLLUP not supported on #{db.database_type}\" unless supports_group_rollup?\n clone(:group_options=>:rollup)\n end",
"def aggregate_after_grouping?; @aggregate_after_grouping; end",
"def commits_rollup\n return commits if @groups.empty?\n @groups.in... | [
"0.7843713",
"0.5746715",
"0.55350065",
"0.5282332",
"0.51886714",
"0.51368845",
"0.5116343",
"0.5096416",
"0.50795084",
"0.5046495",
"0.5004107",
"0.4995787",
"0.49910265",
"0.4987092",
"0.4955337",
"0.49265525",
"0.4913858",
"0.48521537",
"0.4838019",
"0.4783108",
"0.477077... | 0.0 | -1 |
PostgreSQL 9.5+ supports GROUPING SETS | def supports_grouping_sets?
server_version >= 90500
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grouping_sets\n raise Error, \"GROUP BY GROUPING SETS not supported on #{db.database_type}\" unless supports_grouping_sets?\n clone(:group_options=>:\"grouping sets\")\n end",
"def group_by\n end",
"def group_by\n\n end",
"def grouped_duplicates(collection); end",
"def group_by?; @group_... | [
"0.72578466",
"0.64574665",
"0.6363012",
"0.6204091",
"0.60069335",
"0.59798086",
"0.59468204",
"0.59299254",
"0.5926807",
"0.5895744",
"0.58356977",
"0.5835613",
"0.58214027",
"0.5820797",
"0.5771506",
"0.57504207",
"0.57495415",
"0.57292455",
"0.5693723",
"0.5669777",
"0.56... | 0.53189254 | 41 |
True unless insert returning has been disabled for this dataset. | def supports_insert_select?
!@opts[:disable_insert_returning]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def use_insert?\n !use_copy?\n end",
"def insertable?\n persistable? && !_assigning? && inserts_valid\n end",
"def _use_insert_select?(ds)\n (!ds.opts[:select] || ds.opts[:returning]) && ds.supports_insert_select? \n end",
"def _use_insert_select?(ds)\n (!ds.opts[:s... | [
"0.68219227",
"0.6537745",
"0.6484788",
"0.6484788",
"0.64069223",
"0.6354706",
"0.6287502",
"0.62571484",
"0.6256194",
"0.62128913",
"0.61805964",
"0.61404204",
"0.61000156",
"0.608905",
"0.60511166",
"0.6009329",
"0.5975124",
"0.5947837",
"0.5921701",
"0.5902638",
"0.589971... | 0.6667171 | 1 |
PostgreSQL 9.5+ supports the ON CONFLICT clause to INSERT. | def supports_insert_conflict?
server_version >= 90500
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_conflict_sql(sql)\n if opts = @opts[:insert_conflict]\n sql << \" ON CONFLICT\"\n\n if target = opts[:constraint] \n sql << \" ON CONSTRAINT \"\n identifier_append(sql, target)\n elsif target = opts[:target]\n sql << ' '\n ide... | [
"0.70739776",
"0.6682397",
"0.66430146",
"0.6549153",
"0.61710525",
"0.61554676",
"0.60309786",
"0.5983611",
"0.59169257",
"0.58177334",
"0.5790062",
"0.5763213",
"0.5675745",
"0.5648549",
"0.56024617",
"0.55638194",
"0.5546072",
"0.5493775",
"0.54135245",
"0.53846943",
"0.53... | 0.58374584 | 9 |
PostgreSQL 9.3+ supports lateral subqueries | def supports_lateral_subqueries?
server_version >= 90300
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def immediate_subqueries\n my_nodes_tagged(:subquery)\n end",
"def immediate_subqueries\n my_nodes_tagged(:subquery)\n end",
"def subquery\n subqueries.\n compact.\n inject(&:merge)\n end",
"def db_query_transform__subquery query, tmp_table=\"resultset_ta... | [
"0.61836445",
"0.61836445",
"0.58440346",
"0.57117987",
"0.52055484",
"0.5106489",
"0.5051809",
"0.50212246",
"0.4995844",
"0.48434427",
"0.47571778",
"0.47279462",
"0.46696457",
"0.4661552",
"0.4650162",
"0.46348396",
"0.45884544",
"0.45826247",
"0.45632428",
"0.4534584",
"0... | 0.5263417 | 4 |
PostgreSQL supports modifying joined datasets | def supports_modifying_joins?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def def_many_to_many(opts)\n super\n def_association_pks_getter(opts) do\n _join_table_dataset(opts).filter(opts[:left_key]=>send(opts[:left_primary_key])).select_map(opts[:right_key])\n end\n def_association_pks_setter(opts) do |pks|\n checked_transaction ... | [
"0.59809345",
"0.59600765",
"0.58247083",
"0.58247083",
"0.5726891",
"0.5717141",
"0.568549",
"0.5677487",
"0.5632732",
"0.5618993",
"0.5600694",
"0.559718",
"0.55618924",
"0.5530125",
"0.5509987",
"0.54918057",
"0.54159164",
"0.54155934",
"0.5400182",
"0.53923464",
"0.538741... | 0.59849083 | 0 |
PostgreSQL 15+ supports MERGE. | def supports_merge?
server_version >= 150000
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_statement(target, stage)\n <<-SQLMERGE\n begin transaction;\n\n delete from #{target}\n using #{stage}\n where #{target}.id = #{stage}.id;\n insert into #{target}\n select * from #{stage};\n\n end transaction;\n SQLMERGE\n ... | [
"0.6710938",
"0.6681831",
"0.6634573",
"0.64860135",
"0.64847136",
"0.64394313",
"0.6314614",
"0.62681806",
"0.61912584",
"0.6133674",
"0.60186386",
"0.59482306",
"0.58233184",
"0.5804145",
"0.5768289",
"0.57538915",
"0.5709405",
"0.5695733",
"0.5656634",
"0.5585567",
"0.5577... | 0.0 | -1 |
Returning is always supported. | def supports_returning?(type)
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def supported?\n false\n end",
"def supports?\n fail \"Method 'supports?' must be defined\"\n end",
"def allowed?() raise NotImplementedError end",
"def supports?\n raise \"Method 'supports?' must be defined\"\n end",
"def supported\n @supported ||= []\n end",
"def support... | [
"0.843344",
"0.7700669",
"0.7631781",
"0.7629838",
"0.76231104",
"0.7519657",
"0.73208463",
"0.7241568",
"0.7153662",
"0.7140632",
"0.7140632",
"0.71038365",
"0.7073607",
"0.6998771",
"0.6959675",
"0.68993336",
"0.68871474",
"0.68871474",
"0.67963094",
"0.678926",
"0.6754085"... | 0.0 | -1 |
PostgreSQL supports pattern matching via regular expressions | def supports_regexp?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match(pattern); end",
"def match(regexp); end",
"def sql_match_pattern(column, value, **opt)\n '(%s)' % sql_test(column, value, **opt)\n end",
"def regexp_for_sqlite\n if ActiveRecord::Base.connection.adapter_name.eql?(\"SQLite\")\n db = ActiveRecord::Base.connection.instance_variable_get(:@c... | [
"0.7205053",
"0.7067555",
"0.7002273",
"0.6855836",
"0.6748494",
"0.6593988",
"0.6593988",
"0.6397198",
"0.6342313",
"0.63078797",
"0.6296916",
"0.6256902",
"0.6157808",
"0.609136",
"0.6068666",
"0.6062908",
"0.6062908",
"0.60525745",
"0.6016549",
"0.59992856",
"0.5995987",
... | 0.56653345 | 49 |
PostgreSQL 9.5+ supports SKIP LOCKED. | def supports_skip_locked?
server_version >= 90500
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def skip_locked\n cached_dataset(:_skip_locked_ds) do\n raise(Error, 'This dataset does not support skipping locked rows') unless supports_skip_locked?\n clone(:skip_locked=>true)\n end\n end",
"def visit_Arel_Nodes_Lock(o, a = nil)\n # SQL Layer does not support row locks\n... | [
"0.6517862",
"0.6342078",
"0.62830657",
"0.6273183",
"0.62377363",
"0.62230605",
"0.61991656",
"0.6127176",
"0.61240304",
"0.60525775",
"0.60241866",
"0.59789443",
"0.59540343",
"0.594054",
"0.5928728",
"0.58429885",
"0.578368",
"0.57701516",
"0.57493556",
"0.5722337",
"0.571... | 0.54521567 | 44 |
PostgreSQL supports timezones in literal timestamps | def supports_timestamp_timezones?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_timezone(identifier); end",
"def data_timezone(identifier); end",
"def time_zone=(_arg0); end",
"def time_zone=(_arg0); end",
"def timezone(identifier); end",
"def timezone(identifier); end",
"def timezone(identifier); end",
"def data_timezone_identifiers; end",
"def data_timezone_identifi... | [
"0.6196883",
"0.6196883",
"0.61800057",
"0.61800057",
"0.61647296",
"0.61647296",
"0.61647296",
"0.5974996",
"0.5974996",
"0.5974996",
"0.5974996",
"0.5974996",
"0.5974996",
"0.5963424",
"0.5963424",
"0.5963424",
"0.5963424",
"0.5883919",
"0.58165675",
"0.58165675",
"0.581656... | 0.7225166 | 1 |
PostgreSQL 8.4+ supports WINDOW clause. | def supports_window_clause?
server_version >= 80400
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_window_function_eager_limit_strategy(ds, limit_and_offset=limit_and_offset())\n rn = ds.row_number_column \n limit, offset = limit_and_offset\n ds = ds.unordered.select_append{|o| o.row_number.function.over(:partition=>predicate_key, :order=>ds.opts[:order]).as(rn)}.from_self\n... | [
"0.6295806",
"0.5677758",
"0.53731406",
"0.5138089",
"0.50766724",
"0.49283078",
"0.4863528",
"0.4830885",
"0.48183408",
"0.47789818",
"0.47674927",
"0.47634125",
"0.47199786",
"0.46511826",
"0.46487308",
"0.4641359",
"0.4581243",
"0.4581204",
"0.45763293",
"0.45496976",
"0.4... | 0.5358746 | 3 |
PostgreSQL 8.4+ supports window functions | def supports_window_functions?
server_version >= 80400
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_window_function_eager_limit_strategy(ds, limit_and_offset=limit_and_offset())\n rn = ds.row_number_column \n limit, offset = limit_and_offset\n ds = ds.unordered.select_append{|o| o.row_number.function.over(:partition=>predicate_key, :order=>ds.opts[:order]).as(rn)}.from_self\n... | [
"0.5796378",
"0.52517116",
"0.5064502",
"0.4594665",
"0.45769972",
"0.45617715",
"0.45282045",
"0.45062193",
"0.44971704",
"0.44761306",
"0.44666955",
"0.44301325",
"0.43804103",
"0.43185493",
"0.43053",
"0.42579615",
"0.42533994",
"0.42289972",
"0.42187497",
"0.4182494",
"0.... | 0.0 | -1 |
Base support added in 8.4, offset supported added in 9.0, GROUPS and EXCLUDE support added in 11.0. | def supports_window_function_frame_option?(option)
case option
when :rows, :range
true
when :offset
server_version >= 90000
when :groups, :exclude
server_version >= 110000
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_offset(offset); end",
"def offset; end",
"def offset; end",
"def offset; end",
"def offset(*) end",
"def first_offset; end",
"def first_offset; end",
"def check_offset(*)\n false\n end",
"def current_offset; end",
"def limit_and_offset\n r = super\n if r.fi... | [
"0.62224346",
"0.61713517",
"0.61713517",
"0.61713517",
"0.61191493",
"0.58633673",
"0.58633673",
"0.5722773",
"0.57086873",
"0.569345",
"0.5534722",
"0.55226004",
"0.5475919",
"0.5419492",
"0.53431475",
"0.5339308",
"0.5339308",
"0.53376627",
"0.5272072",
"0.5266593",
"0.524... | 0.0 | -1 |
Truncates the dataset. Returns nil. Options: :cascade :: whether to use the CASCADE option, useful when truncating tables with foreign keys. :only :: truncate using ONLY, so child tables are unaffected :restart :: use RESTART IDENTITY to restart any related sequences :only and :restart only work correctly on PostgreSQL 8.4+. Usage: DB[:table].truncate TRUNCATE TABLE "table" DB[:table].truncate(cascade: true, only: true, restart: true) TRUNCATE TABLE ONLY "table" RESTART IDENTITY CASCADE | def truncate(opts = OPTS)
if opts.empty?
super()
else
clone(:truncate_opts=>opts).truncate
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def truncate!\n return if truncated?\n update_column :metadata, nil\n end",
"def truncate\n connection.truncate(table_name)\n end",
"def _truncate_sql(table)\n to = @opts[:truncate_opts] || OPTS\n \"TRUNCATE TABLE#{' ONLY' if to[:only]} #{table}#{' RESTART IDENTITY' if to[:restar... | [
"0.70971954",
"0.70765924",
"0.7043742",
"0.69265467",
"0.6460157",
"0.62650967",
"0.62350446",
"0.62074137",
"0.61999035",
"0.60787535",
"0.6010918",
"0.6002308",
"0.5951963",
"0.5832811",
"0.5784054",
"0.5650781",
"0.5630688",
"0.5513483",
"0.5496783",
"0.5469438",
"0.54579... | 0.63920975 | 5 |
Use WITH TIES when limiting the result set to also include additional rules that have the same results for the order column as the final row. Requires PostgreSQL 13. | def with_ties
clone(:limit_with_ties=>true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_distinct_on_eager_limit_strategy(ds)\n keys = predicate_key\n ds.distinct(*keys).order_prepend(*keys)\n end",
"def apply_eager_graph_limit_strategy(strategy, ds)\n case strategy\n when :distinct_on\n apply_distinct_on_eager_limit_strategy(ds.order_p... | [
"0.5299166",
"0.5172057",
"0.48928833",
"0.48259202",
"0.48073283",
"0.4780117",
"0.4733667",
"0.4678507",
"0.46374992",
"0.46358874",
"0.4614721",
"0.4611258",
"0.45715606",
"0.45108175",
"0.4510816",
"0.44654173",
"0.44593266",
"0.44482273",
"0.44270986",
"0.44252208",
"0.4... | 0.0 | -1 |
If returned primary keys are requested, use RETURNING unless already set on the dataset. If RETURNING is already set, use existing returning values. If RETURNING is only set to return a single columns, return an array of just that column. Otherwise, return an array of hashes. | def _import(columns, values, opts=OPTS)
if @opts[:returning]
# no transaction: our multi_insert_sql_strategy should guarantee
# that there's only ever a single statement.
sql = multi_insert_sql(columns, values)[0]
returning_fetch_rows(sql).map{|v| v.length == 1 ? v.values.first : v}
elsif opts[:return] == :primary_key
returning(insert_pk)._import(columns, values, opts)
else
super
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def returning(*values)\n if values.empty?\n cached_dataset(:_returning_ds) do\n raise Error, \"RETURNING is not supported on #{db.database_type}\" unless supports_returning?(:insert)\n clone(:returning=>EMPTY_ARRAY)\n end\n else\n raise Error, \"RETURNING is not sup... | [
"0.66599965",
"0.6531039",
"0.63882446",
"0.6354546",
"0.6209912",
"0.6093167",
"0.60481465",
"0.58934253",
"0.5852828",
"0.57763964",
"0.5716967",
"0.5696746",
"0.566648",
"0.5648507",
"0.5596756",
"0.5550032",
"0.55439866",
"0.5517233",
"0.550438",
"0.5496207",
"0.5445",
... | 0.541241 | 23 |
Append the INSERT sql used in a MERGE | def _merge_insert_sql(sql, data)
sql << " THEN INSERT "
columns, values = _parse_insert_sql_args(data[:values])
_insert_columns_sql(sql, columns)
if override = data[:override]
sql << override
end
_insert_values_sql(sql, values)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_insert(*values, &block)\n h = {:type=>:insert, :values=>values}\n if override = @opts[:override]\n h[:override] = insert_override_sql(String.new)\n end\n _merge_when(h, &block)\n end",
"def insert_conflict_sql(sql)\n if opts = @opts[:insert_conflict]\n ... | [
"0.7337785",
"0.7198908",
"0.71126693",
"0.707527",
"0.68403673",
"0.6808274",
"0.6782001",
"0.65473086",
"0.64943826",
"0.6456124",
"0.6433498",
"0.6402454",
"0.6376985",
"0.63509864",
"0.6320931",
"0.6320931",
"0.626627",
"0.6218312",
"0.621048",
"0.6189745",
"0.61735564",
... | 0.80021787 | 0 |
Format TRUNCATE statement with PostgreSQL specific options. | def _truncate_sql(table)
to = @opts[:truncate_opts] || OPTS
"TRUNCATE TABLE#{' ONLY' if to[:only]} #{table}#{' RESTART IDENTITY' if to[:restart]}#{' CASCADE' if to[:cascade]}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notice_nosql_statement(nosql_statement)\n return unless record_sql?\n\n @nosql_statement = Database.truncate_query(nosql_statement)\n nil\n end",
"def truncate_table\n\t\t\t transaction { connection.execute(\"TRUNCATE TABLE #{quoted_table_name};\") }\n\t\t end",
"def exe... | [
"0.5507991",
"0.54600996",
"0.5273651",
"0.5187143",
"0.50678164",
"0.4914534",
"0.48577395",
"0.48543635",
"0.4853718",
"0.4715146",
"0.47071767",
"0.46592757",
"0.46435788",
"0.46198285",
"0.45876056",
"0.45748812",
"0.4544344",
"0.45238018",
"0.4521532",
"0.45109248",
"0.4... | 0.6143214 | 0 |
Use from_self for aggregate dataset using VALUES. | def aggreate_dataset_use_from_self?
super || @opts[:values]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aggregate_values(rows)\n # Convert rows into hash where each key is a column name and the each\n # value is an array of values for that column\n cols = OrderedHash.new\n rows.each do |row|\n row.each do |k,v|\n cols[k] ||= []\n cols[k] << v\n ... | [
"0.55833846",
"0.55151165",
"0.5500441",
"0.5476202",
"0.54460794",
"0.5347169",
"0.5315667",
"0.5272025",
"0.5245065",
"0.5163853",
"0.51637846",
"0.51460284",
"0.5136454",
"0.5136451",
"0.51340026",
"0.51255244",
"0.5118315",
"0.5113868",
"0.51118565",
"0.5096498",
"0.50929... | 0.64051324 | 0 |
Allow truncation of multiple source tables. | def check_truncation_allowed!
raise(InvalidOperation, "Grouped datasets cannot be truncated") if opts[:group]
raise(InvalidOperation, "Joined datasets cannot be truncated") if opts[:join]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_target_table\n self.target_table = source_table if target_table.blank?\n end",
"def tables_for_sql\n @tables_for_sql ||= RailsRedshiftReplicator.replicable_target_tables.join(\",\")\n end",
"def _truncate_sql(table)\n to = @opts[:truncate_opts] || OPTS\n \"TRUNCATE T... | [
"0.59406096",
"0.57482046",
"0.5635725",
"0.547253",
"0.53894407",
"0.53232217",
"0.53206587",
"0.52276355",
"0.5222187",
"0.52083164",
"0.52072746",
"0.5196061",
"0.5178575",
"0.5163621",
"0.51179594",
"0.51079535",
"0.5092086",
"0.5033839",
"0.5013097",
"0.5013097",
"0.5013... | 0.5296199 | 7 |
Only include the primary table in the main delete clause | def delete_from_sql(sql)
sql << ' FROM '
source_list_append(sql, @opts[:from][0..0])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(table, ids) # abstract\n end",
"def prepared_delete\n # SEQUEL5: Remove\n cached_prepared_statement(:fixed, :delete){prepare_statement(filter(prepared_statement_key_array(primary_key)), :delete)}\n end",
"def delete(table, where)\n sql = \"delete from #{table} #{wher... | [
"0.71483934",
"0.7042767",
"0.676697",
"0.6694531",
"0.66897273",
"0.66391444",
"0.6638879",
"0.6621127",
"0.6621127",
"0.6612789",
"0.6595038",
"0.65888524",
"0.6579451",
"0.6510613",
"0.6502417",
"0.64435554",
"0.6410139",
"0.6336354",
"0.6303365",
"0.63010603",
"0.6294832"... | 0.59046894 | 65 |
Use USING to specify additional tables in a delete query | def delete_using_sql(sql)
join_from_sql(:USING, sql)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_sql(opts = nil)\n opts = opts ? @opts.merge(opts) : @opts\n\n if opts[:group]\n raise Error::InvalidOperation, \"Grouped datasets cannot be deleted from\"\n elsif opts[:from].is_a?(Array) && opts[:from].size > 1\n raise Error::InvalidOperation, \"Joined datasets cannot be de... | [
"0.63203835",
"0.6251078",
"0.6079405",
"0.60615814",
"0.60326934",
"0.6020745",
"0.6006609",
"0.59675026",
"0.5950655",
"0.5901165",
"0.58806187",
"0.5856725",
"0.5830617",
"0.58274776",
"0.57967013",
"0.5768996",
"0.5765135",
"0.5707902",
"0.56950194",
"0.5692454",
"0.56786... | 0.76211977 | 1 |
Add ON CONFLICT clause if it should be used | def insert_conflict_sql(sql)
if opts = @opts[:insert_conflict]
sql << " ON CONFLICT"
if target = opts[:constraint]
sql << " ON CONSTRAINT "
identifier_append(sql, target)
elsif target = opts[:target]
sql << ' '
identifier_append(sql, Array(target))
if conflict_where = opts[:conflict_where]
sql << " WHERE "
literal_append(sql, conflict_where)
end
end
if values = opts[:update]
sql << " DO UPDATE SET "
update_sql_values_hash(sql, values)
if update_where = opts[:update_where]
sql << " WHERE "
literal_append(sql, update_where)
end
else
sql << " DO NOTHING"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sql_for_on_duplicate_key_ignore( *args ) # :nodoc:\n arg = args.first\n conflict_target = sql_for_conflict_target( arg ) if arg.is_a?( Hash )\n \" ON CONFLICT #{conflict_target}DO NOTHING\"\n end",
"def sql_for_on_duplicate_key_ignore( table_name, *args ) # :nodoc:\n arg = args.first\n confli... | [
"0.7435312",
"0.72036123",
"0.63911206",
"0.63625365",
"0.63076633",
"0.62139535",
"0.5894587",
"0.5893596",
"0.58595127",
"0.58219266",
"0.57686543",
"0.55642307",
"0.5488854",
"0.536428",
"0.5363308",
"0.53116924",
"0.5297403",
"0.5259442",
"0.52361304",
"0.5174694",
"0.513... | 0.68958986 | 2 |
Include aliases when inserting into a single table on PostgreSQL 9.5+. | def insert_into_sql(sql)
sql << " INTO "
if (f = @opts[:from]) && f.length == 1
identifier_append(sql, server_version >= 90500 ? f.first : unaliased_identifier(f.first))
else
source_list_append(sql, f)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quote_identifier_append(sql, name)\n name = (table_mappings[name.to_sym] || name) if name.respond_to?(:to_sym)\n super(sql, name)\n end",
"def addTableAlias(theAlias)\n @metadata.addTableAlias(theAlias)\n end",
"def addColumnAlias(theAlias)\n @metadata.addColumnAlias(theAlias)\n ... | [
"0.6124453",
"0.60013545",
"0.59401596",
"0.5806555",
"0.5685734",
"0.5633251",
"0.55919856",
"0.5528682",
"0.55130064",
"0.54824096",
"0.54548544",
"0.5448377",
"0.54266876",
"0.5383294",
"0.53749365",
"0.5368234",
"0.5361845",
"0.5356271",
"0.53260094",
"0.5319536",
"0.5317... | 0.5712637 | 4 |
Return the primary key to use for RETURNING in an INSERT statement | def insert_pk
(f = opts[:from]) && !f.empty? && (t = f.first)
case t
when Symbol, String, SQL::Identifier, SQL::QualifiedIdentifier
if pk = db.primary_key(t)
Sequel::SQL::Identifier.new(pk)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def autoincrementing_primary_key\n primary_key\n end",
"def autoincrementing_primary_key\n primary_key\n end",
"def insert_pk\n if (f = opts[:from]) && !f.empty?\n case t = f.first\n when Symbol, String, SQL::Identifier, SQL::QualifiedIdentifier\n if ... | [
"0.8037107",
"0.8037107",
"0.7785286",
"0.76749134",
"0.7557144",
"0.7552393",
"0.7490722",
"0.74085295",
"0.73910064",
"0.73910064",
"0.73910064",
"0.7290003",
"0.7267558",
"0.7257927",
"0.7231899",
"0.7226765",
"0.72228605",
"0.72121257",
"0.7200792",
"0.71392804",
"0.71334... | 0.7425948 | 7 |
Support OVERRIDING SYSTEM|USER VALUE in insert statements | def insert_override_sql(sql)
case opts[:override]
when :system
sql << " OVERRIDING SYSTEM VALUE"
when :user
sql << " OVERRIDING USER VALUE"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login_failure(user=nil)\n blank(\n la_ip: ::GDO::Net::GDT_IP.current,\n la_user: user == nil ? nil : user.get_id,\n ).insert\n end",
"def add_user(db, user_name)\r\nadd_user = '\r\n\r\n\tINSERT INTO users \r\n\r\n\t(name, cache, expected_income, actual_income, expenses, month)\r\n\tVALUES (?... | [
"0.5437121",
"0.54056925",
"0.53587854",
"0.5357034",
"0.53318524",
"0.5330959",
"0.5315511",
"0.5309238",
"0.52904433",
"0.5285804",
"0.5285804",
"0.5282915",
"0.5274498",
"0.52641934",
"0.5258501",
"0.5258501",
"0.5258501",
"0.5237348",
"0.5202416",
"0.5189946",
"0.518118",... | 0.6451863 | 0 |
For multiple table support, PostgreSQL requires at least two from tables, with joins allowed. | def join_from_sql(type, sql)
if(from = @opts[:from][1..-1]).empty?
raise(Error, 'Need multiple FROM tables if updating/deleting a dataset with JOINs') if @opts[:join]
else
sql << ' ' << type.to_s << ' '
source_list_append(sql, from)
select_join_sql(sql)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_tables(db)\n db.execute(\"SELECT users.user_name, platform.platform_name, music.artist, music.song, music.explicit_lyrics FROM music JOIN users ON music.user_id = users.id JOIN platform ON music.platform_id = platform.id\")\nend",
"def join(*args)\n\t\tif args.count > 1\n\t\t\tjoins = args.map { |arg| ... | [
"0.6400713",
"0.63369375",
"0.6314119",
"0.6087215",
"0.6051302",
"0.60380393",
"0.5940293",
"0.5855021",
"0.58443964",
"0.5838234",
"0.5803235",
"0.57699335",
"0.57361025",
"0.57264787",
"0.5725699",
"0.57225955",
"0.5708174",
"0.5697971",
"0.5676513",
"0.5663057",
"0.566167... | 0.6261544 | 3 |
Support table aliases for USING columns | def join_using_clause_using_sql_append(sql, using_columns)
if using_columns.is_a?(SQL::AliasedExpression)
super(sql, using_columns.expression)
sql << ' AS '
identifier_append(sql, using_columns.alias)
else
super
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table_alias\r\n @table_alias || from_table_name\r\n end",
"def build_table_aliases(from)\n # for the targets\n returning({}) do |aliases|\n from.map(&:to_s).sort.map(&:to_sym).each_with_index do |plural, t_index|\n table = plural._as_class.table_name\n plural._as_cl... | [
"0.73351204",
"0.68861693",
"0.6870926",
"0.6854861",
"0.6820711",
"0.6785581",
"0.6688088",
"0.66173035",
"0.6586291",
"0.65842116",
"0.6562811",
"0.6548786",
"0.65157646",
"0.64271873",
"0.63693255",
"0.63578135",
"0.6356919",
"0.6354602",
"0.6354602",
"0.6354602",
"0.63296... | 0.66456246 | 7 |
Use a generic blob quoting method, hopefully overridden in one of the subadapter methods | def literal_blob_append(sql, v)
sql << "'" << v.gsub(/[\000-\037\047\134\177-\377]/n){|b| "\\#{("%o" % b[0..1].unpack("C")[0]).rjust(3, '0')}"} << "'"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quote(value, column = nil)\n case value\n when String, ActiveSupport::Multibyte::Chars\n value_S = value.to_s\n if column && column.type == :binary && column.class.respond_to?(:string_to_binary)\n \"'#{column.class.string_to_binary(value_S)}'\"\n ... | [
"0.6421807",
"0.64217883",
"0.64217883",
"0.64217883",
"0.64217883",
"0.64217883",
"0.64217883",
"0.64217883",
"0.64217883",
"0.64217883",
"0.64217883",
"0.64217883",
"0.64217883",
"0.64217883",
"0.64217883",
"0.64217883",
"0.64217883",
"0.64217883",
"0.64217883",
"0.64217883",... | 0.61955583 | 63 |
PostgreSQL uses FALSE for false values | def literal_false
'false'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_boolean(val)\n if adapter == :postgres\n val ? 'TRUE' : 'FALSE'\n else\n val ? '1' : '0'\n end\n end",
"def to_bool() false end",
"def sql_boolean\n BooleanExpression.new(:NOOP, self)\n end",
"def sql_boolean\n BooleanExpression.new(:NOOP, self)\n ... | [
"0.7533041",
"0.73353285",
"0.71181154",
"0.71181154",
"0.70923305",
"0.69954467",
"0.68945616",
"0.68405515",
"0.676199",
"0.6748788",
"0.67112726",
"0.6697309",
"0.6685205",
"0.66401607",
"0.66356605",
"0.6620472",
"0.660391",
"0.6573759",
"0.65710753",
"0.6537756",
"0.6525... | 0.68685883 | 7 |
PostgreSQL quotes NaN and Infinity. | def literal_float(value)
if value.finite?
super
elsif value.nan?
"'NaN'"
elsif value.infinite? == 1
"'Infinity'"
else
"'-Infinity'"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allow_nan?()\n #This is a stub, used for indexing\n end",
"def ∞ℂ; ::Float::INFINITY_COMPLEX; end",
"def nan\n BigDecimal('0')/BigDecimal('0')\n end",
"def handle_nan(result)\n result.nan? ? 0.0 : result\n end",
"def handle_nan(result)\n result.nan? ? 0.0 : ... | [
"0.675201",
"0.6434023",
"0.63592994",
"0.62690026",
"0.62690026",
"0.5924871",
"0.5916958",
"0.57710654",
"0.5722384",
"0.5592909",
"0.5577168",
"0.555948",
"0.54728085",
"0.54715145",
"0.5422187",
"0.5416626",
"0.5352652",
"0.5331749",
"0.5331749",
"0.53267884",
"0.5315962"... | 0.6937389 | 0 |
Handle Ruby integers outside PostgreSQL bigint range specially. | def literal_integer(v)
if v > 9223372036854775807 || v < -9223372036854775808
literal_integer_outside_bigint_range(v)
else
v.to_s
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def literal_integer_outside_bigint_range(v)\n raise IntegerOutsideBigintRange, \"attempt to literalize Ruby integer outside PostgreSQL bigint range: #{v}\"\n end",
"def test_do_not_raise_when_int_is_not_wider_than_64bit\n value = 9223372036854775807\n assert_equal \"'9223372036854775807'\",... | [
"0.8245709",
"0.6992368",
"0.66835093",
"0.6479705",
"0.64078766",
"0.6316349",
"0.63103896",
"0.62356555",
"0.6216988",
"0.6173353",
"0.6133337",
"0.6091662",
"0.6076664",
"0.6071689",
"0.6012722",
"0.596731",
"0.5948034",
"0.5931467",
"0.5915999",
"0.58987486",
"0.5872905",... | 0.7218923 | 1 |
Raise IntegerOutsideBigintRange when attempting to literalize Ruby integer outside PostgreSQL bigint range, so PostgreSQL doesn't treat the value as numeric. | def literal_integer_outside_bigint_range(v)
raise IntegerOutsideBigintRange, "attempt to literalize Ruby integer outside PostgreSQL bigint range: #{v}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def literal_integer(v)\n if v > 9223372036854775807 || v < -9223372036854775808\n literal_integer_outside_bigint_range(v)\n else\n v.to_s\n end\n end",
"def test_do_not_raise_when_int_is_not_wider_than_64bit\n value = 9223372036854775807\n assert_equal \"'922... | [
"0.70062757",
"0.67205375",
"0.6706813",
"0.63642526",
"0.63092715",
"0.6266042",
"0.62429863",
"0.61111265",
"0.59855026",
"0.5961269",
"0.5949774",
"0.5680745",
"0.567375",
"0.5669552",
"0.56378376",
"0.5611179",
"0.56030303",
"0.55616546",
"0.55498075",
"0.5537962",
"0.552... | 0.8686653 | 0 |
Assume that SQL standard quoting is on, per Sequel's defaults | def literal_string_append(sql, v)
sql << "'" << v.gsub("'", "''") << "'"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quote(s, column = nil)\n dummy_conn.quote(s)\n end",
"def sql_quoted(value)\n Arel::Nodes.build_quoted(value)\n end",
"def quoted(value)\n sql _scope.connection.quote(value)\n end",
"def quoted(value)\n sql _scope.connection.quote(value)\n end",
"def cust... | [
"0.73580086",
"0.67877775",
"0.67741084",
"0.67741084",
"0.6671209",
"0.661895",
"0.6582974",
"0.65012497",
"0.6495129",
"0.64906394",
"0.6488084",
"0.648066",
"0.648066",
"0.648066",
"0.648066",
"0.648066",
"0.648066",
"0.648066",
"0.648066",
"0.648066",
"0.648066",
"0.648... | 0.60761344 | 86 |
PostgreSQL uses true for true values | def literal_true
'true'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_boolean(val)\n if adapter == :postgres\n val ? 'TRUE' : 'FALSE'\n else\n val ? '1' : '0'\n end\n end",
"def sql_boolean\n self\n end",
"def to_bool() true end",
"def column_value_boolean\n case Utilities.adapter\n when 'mysql2', 'postgr... | [
"0.76973087",
"0.7310421",
"0.7061751",
"0.6996198",
"0.69679326",
"0.69623554",
"0.6950713",
"0.6950713",
"0.6926004",
"0.6911913",
"0.68247306",
"0.6776206",
"0.6755321",
"0.67295533",
"0.66371375",
"0.661686",
"0.66165036",
"0.6613014",
"0.65885556",
"0.65867907",
"0.65554... | 0.6945706 | 8 |
PostgreSQL supports multiple rows in INSERT. | def multi_insert_sql_strategy
:values
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert!(*rows)\n Mao.sql(with_options(:insert => rows.flatten).sql) do |pg_result|\n if @options[:returning]\n pg_result.map {|result| Mao.normalize_result(result, @col_types)}\n else\n pg_result.cmd_tuples\n end\n end\n end",
"def multi_insert(tuples)\n pks = rel... | [
"0.7640881",
"0.74330044",
"0.69389695",
"0.69068533",
"0.66917443",
"0.66913056",
"0.6682041",
"0.6633522",
"0.65172905",
"0.6516788",
"0.65022826",
"0.6486905",
"0.6388606",
"0.63865644",
"0.6357242",
"0.6326598",
"0.62928814",
"0.62393683",
"0.62268454",
"0.6203298",
"0.61... | 0.6972604 | 2 |
Dataset options that do not affect the generated SQL. | def non_sql_option?(key)
super || key == :cursor || key == :insert_conflict
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _metadata_dataset\n super.with_convert_smallint_to_bool(false)\n end",
"def datatable_exclude_fields\n # None\n []\n end",
"def options\n {\n keywords: ['Boolean', \"Quote all keywords, not just reserved words\"],\n restrict: ['String', \"Restri... | [
"0.6126969",
"0.6093773",
"0.60819745",
"0.6073446",
"0.5967321",
"0.5946746",
"0.59196484",
"0.58290535",
"0.5820168",
"0.5818987",
"0.581032",
"0.57358986",
"0.5735619",
"0.5730669",
"0.57108414",
"0.5682038",
"0.56603724",
"0.5653939",
"0.5626986",
"0.56221044",
"0.5605688... | 0.0 | -1 |
PostgreSQL requires parentheses around compound datasets if they use CTEs, and using them in other places doesn't hurt. | def compound_dataset_sql_append(sql, ds)
sql << '('
super
sql << ')'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sql_literal(*)\n @dataset.sql\n end",
"def with(name, dataset, opts=OPTS)\n raise(Error, 'This dataset does not support common table expressions') unless supports_cte?\n if hoist_cte?(dataset)\n s, ds = hoist_cte(dataset)\n s.with(name, ds, opts)\n else\n clone(:with=>... | [
"0.5690019",
"0.5614801",
"0.525116",
"0.52488124",
"0.52488124",
"0.51948553",
"0.5151954",
"0.5031857",
"0.50287414",
"0.50183415",
"0.50035864",
"0.49730965",
"0.4959759",
"0.4919089",
"0.4887447",
"0.4861835",
"0.4861835",
"0.4861835",
"0.48376042",
"0.481184",
"0.4803341... | 0.5490127 | 2 |
Backslash is supported by default as the escape character on PostgreSQL, and using ESCAPE can break LIKE ANY() usage. | def requires_like_escape?
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_escaped_for_sql_like\n gsub(/[\\\\%_]/) { |x| '\\\\' + x }.gsub(\"*\", \"%\")\n end",
"def escape_wildcards(unescaped)\n case ActiveRecord::Base.connection.adapter_name\n when \"Mysql2\".freeze\n # Necessary for MySQL\n unescaped.to_s.gsub(/([\\\\%_])/, '\\\\\\\\\\\\1')\n ... | [
"0.69977903",
"0.68312544",
"0.68172544",
"0.6625503",
"0.6295788",
"0.6227684",
"0.6224164",
"0.6196449",
"0.6193427",
"0.6176893",
"0.6164101",
"0.6155538",
"0.6151317",
"0.6123133",
"0.6092577",
"0.6091664",
"0.60775405",
"0.60621685",
"0.6015789",
"0.59425694",
"0.5929683... | 0.58517337 | 27 |
Support FETCH FIRST WITH TIES on PostgreSQL 13+. | def select_limit_sql(sql)
l = @opts[:limit]
o = @opts[:offset]
return unless l || o
if @opts[:limit_with_ties]
if o
sql << " OFFSET "
literal_append(sql, o)
end
if l
sql << " FETCH FIRST "
literal_append(sql, l)
sql << " ROWS WITH TIES"
end
else
if l
sql << " LIMIT "
literal_append(sql, l)
end
if o
sql << " OFFSET "
literal_append(sql, o)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_distinct_on_eager_limit_strategy(ds)\n keys = predicate_key\n ds.distinct(*keys).order_prepend(*keys)\n end",
"def first **args\n query( **( { order: \"@rid\" , limit: 1 }.merge args)).execute(reduce: true)\n\tend",
"def oldest(constraints = {})\n constraints.merge!... | [
"0.5735091",
"0.5717865",
"0.5541578",
"0.54762655",
"0.53705156",
"0.51928",
"0.51910776",
"0.51767975",
"0.5150512",
"0.51314545",
"0.51211715",
"0.5107328",
"0.5053165",
"0.49903002",
"0.498065",
"0.49799594",
"0.49768218",
"0.49761242",
"0.49740243",
"0.49682325",
"0.4964... | 0.0 | -1 |
Support FOR SHARE locking when using the :share lock style. Use SKIP LOCKED if skipping locked rows. | def select_lock_sql(sql)
lock = @opts[:lock]
if lock == :share
sql << ' FOR SHARE'
else
super
end
if lock
if @opts[:skip_locked]
sql << " SKIP LOCKED"
elsif @opts[:nowait]
sql << " NOWAIT"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def for_share\n lock_style(:share)\n end",
"def nolock\n clone(:table_options => \"(NOLOCK)\")\n end",
"def skip_locked\n cached_dataset(:_skip_locked_ds) do\n raise(Error, 'This dataset does not support skipping locked rows') unless supports_skip_locked?\n clone(:ski... | [
"0.70884025",
"0.6361162",
"0.62005144",
"0.6196953",
"0.6189135",
"0.6172573",
"0.6153694",
"0.60519814",
"0.6024574",
"0.6016043",
"0.60124713",
"0.5951911",
"0.5951208",
"0.5945349",
"0.59318465",
"0.59261966",
"0.592478",
"0.59171903",
"0.5903963",
"0.5874665",
"0.5862838... | 0.66496354 | 1 |
Support VALUES clause instead of the SELECT clause to return rows. | def select_values_sql(sql)
sql << "VALUES "
expression_list_append(sql, opts[:values])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_values\n value = nil\n assert_nothing_raised do\n value = ActiveRecord::Base.connection.send(:select_rows, \"VALUES('ur', 'doin', 'it', 'right')\")\n end\n assert_equal [['ur', 'doin', 'it', 'right']], value\n end",
"def select_values(sql, name = nil)\n result = select_rows(sql,... | [
"0.7333736",
"0.6650351",
"0.6242213",
"0.62295794",
"0.6073188",
"0.60719794",
"0.59351194",
"0.59288603",
"0.58959985",
"0.5886909",
"0.58362275",
"0.58324695",
"0.57895106",
"0.5780254",
"0.5780254",
"0.5780254",
"0.57623494",
"0.5755752",
"0.57550055",
"0.5736297",
"0.572... | 0.7835908 | 0 |
Use WITH RECURSIVE instead of WITH if any of the CTEs is recursive | def select_with_sql_base
opts[:with].any?{|w| w[:recursive]} ? "WITH RECURSIVE " : super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursive => nil",
"def recurse_result_set(result, options = {}, &block)\n return result unless block_given? \n inner_recursion = options.delete(:inner_recursion)\n result_set = inner_recursion ? result : result.dup\n \n parent_id = (options.delete(:parent... | [
"0.6101633",
"0.58727944",
"0.5860632",
"0.58225715",
"0.57552505",
"0.57173055",
"0.570878",
"0.5668911",
"0.5499742",
"0.5494343",
"0.5467305",
"0.54537404",
"0.5439365",
"0.5438485",
"0.53512436",
"0.5348822",
"0.53355944",
"0.5330341",
"0.5294763",
"0.5254271",
"0.5241992... | 0.53558385 | 14 |
Support PostgreSQL 14+ CTE SEARCH/CYCLE clauses | def select_with_sql_cte(sql, cte)
super
select_with_sql_cte_search_cycle(sql, cte)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def immediate_subqueries\n my_nodes_tagged(:subquery)\n end",
"def immediate_subqueries\n my_nodes_tagged(:subquery)\n end",
"def find_related_nodes_via_cypher(query_string, options = {})\n query_string = \"\n #{neo_self_match_clause}\n #{query_string}\n \"\n # t1 =... | [
"0.52050734",
"0.52050734",
"0.5193499",
"0.51634336",
"0.49859515",
"0.49299592",
"0.48931837",
"0.48773682",
"0.48163575",
"0.48068506",
"0.4787729",
"0.477681",
"0.47724617",
"0.4771895",
"0.47612202",
"0.4757136",
"0.4750637",
"0.47494748",
"0.47455943",
"0.47416502",
"0.... | 0.58591795 | 0 |
The version of the database server | def server_version
db.server_version(@opts[:server])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def version\n @version ||= exec('SHOW server_version')[0]['server_version'].split[0]\n end",
"def get_server_version\n server_info[:server_version]\n end",
"def db_version\n migration_meta_node[:_db_version]\n end",
"def server_version; end",
"def server_version\n check_c... | [
"0.85410744",
"0.81251967",
"0.8072402",
"0.8030856",
"0.7889446",
"0.78843343",
"0.7822001",
"0.7734123",
"0.7734123",
"0.76928204",
"0.7673027",
"0.76689583",
"0.76477915",
"0.7637135",
"0.7603097",
"0.7603097",
"0.7603097",
"0.7603097",
"0.7603097",
"0.7603097",
"0.7603097... | 0.8844359 | 0 |
PostgreSQL 9.4+ supports the FILTER clause for aggregate functions. | def supports_filtered_aggregates?
server_version >= 90400
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_agg(field:, value:, &block)\r\n agg = { agg: { filter: { term: { field => value } } } }\r\n base_agg(agg, block)\r\n end",
"def filter_expr(*args, &block)\n schema_utility_dataset.literal(schema_utility_dataset.send(:filter_expr, *args, &block))\n end",
"def filter_expr(*args, &... | [
"0.68197376",
"0.63455915",
"0.6330108",
"0.6330108",
"0.6127705",
"0.6127705",
"0.5911166",
"0.583755",
"0.5799499",
"0.57693523",
"0.57682407",
"0.57682407",
"0.57682407",
"0.56768763",
"0.56580806",
"0.5655221",
"0.563342",
"0.563342",
"0.5628486",
"0.5573211",
"0.552571",... | 0.5316833 | 37 |
PostgreSQL supports quoted function names. | def supports_quoted_function_names?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def irregular_function_sql(f)\n \"#{f.f}(#{literal(f.arg1)} #{f.joiner} #{literal(f.arg2)})\"\n end",
"def function_sql(f)\n args = f.args\n \"#{f.f}#{args.empty? ? '()' : literal(args)}\"\n end",
"def function(name, *args)\n SQL::Function.new(name, *args)\n end",
"def quoted... | [
"0.6741665",
"0.6719341",
"0.64273614",
"0.64095914",
"0.62986046",
"0.6254364",
"0.61536664",
"0.61536664",
"0.61536664",
"0.61536664",
"0.61536664",
"0.61536664",
"0.61536664",
"0.61536664",
"0.61536664",
"0.61536664",
"0.61536664",
"0.61536664",
"0.61536664",
"0.61536664",
... | 0.7917335 | 1 |
Concatenate the expressions with a space in between | def full_text_string_join(cols)
cols = Array(cols).map{|x| SQL::Function.new(:COALESCE, x, '')}
cols = cols.zip([' '] * cols.length).flatten
cols.pop
SQL::StringExpression.new(:'||', *cols)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n \"(#{@x.map(&:to_s).join(\" + \")})\"\n end",
"def expr_to_s\n buf = ''\n each_term do |term|\n if term[:operator]\n buf << term[:operator]\n end\n buf << term[:token]\n end\n buf\n end",
"def to_s\n # Wrap the expression on the left/right in parentheses... | [
"0.63969976",
"0.63577175",
"0.6309748",
"0.6276193",
"0.6244219",
"0.62273544",
"0.62001157",
"0.619735",
"0.6179301",
"0.61741954",
"0.61233836",
"0.6113048",
"0.6025421",
"0.59900457",
"0.59634244",
"0.59588397",
"0.5937076",
"0.59319395",
"0.5896875",
"0.58860207",
"0.587... | 0.5863618 | 21 |
Use FROM to specify additional tables in an update query | def update_from_sql(sql)
join_from_sql(:FROM, sql)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_table_sql(sql)\n sql << ' '\n source_list_append(sql, @opts[:from][0..0])\n end",
"def update_from(from_table, *args, &block)\n\n configure_transfer(from_table, *args) { yield }\n\n @current_operation = StatusReport.instance.add_operation :source => @from_table,\n ... | [
"0.630731",
"0.6088034",
"0.5901598",
"0.5883422",
"0.5592899",
"0.55487484",
"0.5529329",
"0.54990935",
"0.5488189",
"0.5416212",
"0.5406827",
"0.5382143",
"0.5381436",
"0.53802943",
"0.5377935",
"0.5377765",
"0.53237104",
"0.5322136",
"0.5301938",
"0.5299105",
"0.5299105",
... | 0.7206524 | 1 |
Only include the primary table in the main update clause | def update_table_sql(sql)
sql << ' '
source_list_append(sql, @opts[:from][0..0])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_without_callbacks\r\n where_clause_terms = [self.class.primary_key, quoted_id].transpose.map do |pair| \r\n \"(#{connection.quote_column_name(pair[0])} = #{pair[1]})\"\r\n end\r\n where_clause = where_clause_terms.join(\" AND \")\r\n connection.update(\r\n ... | [
"0.6562034",
"0.641759",
"0.62743306",
"0.6030083",
"0.60216254",
"0.60174334",
"0.59798825",
"0.5968073",
"0.5957783",
"0.593133",
"0.5909523",
"0.58660275",
"0.58623",
"0.58623",
"0.5852555",
"0.5752741",
"0.5744804",
"0.57255346",
"0.5718237",
"0.56968045",
"0.56924266",
... | 0.56624854 | 23 |
added to test that whitespace before/after code system name and codes is stripped | def test_is_in_code_set_strip_whitespace
entry = Entry.new
entry.add_code(" 854935 ", " RxNorm ")
entry.add_code(" 44556699 ", "RxNorm ")
entry.add_code(" 1245 ", " Junk ")
assert entry.is_in_code_set?([{'set' => 'RxNorm', 'values' => ['854935', '5440']},
{'set' => 'SNOMED-CT', 'values' => ['24601']}])
assert !entry.is_in_code_set?([{'set' => ' RxNorm ', 'values' => ['854935', '5440']},
{'set' => 'SNOMED-CT', 'values' => ['24601']}])
assert !entry.is_in_code_set?([{'set' => 'RxNorm', 'values' => [' 854935 ', '5440']},
{'set' => 'SNOMED-CT', 'values' => ['24601']}])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trimming_for_diff_text(code)\n # gsub(/^\\s*$/, '') means remove empty lines\n code.strip.gsub(/^\\s*$/, '')\n end",
"def strip_listing(code)\n code = code.dup\n code.gsub!(/\\t/, \" \")\n lines = code.split(\"\\n\")\n first_code_line = lines.index { |l| l =~ /\\S/ }\n ... | [
"0.64976764",
"0.6289234",
"0.6256693",
"0.62021565",
"0.61930275",
"0.6148575",
"0.613461",
"0.61342424",
"0.6071139",
"0.6060686",
"0.60496193",
"0.6047944",
"0.6047377",
"0.6003417",
"0.5969678",
"0.5964537",
"0.5934929",
"0.5926174",
"0.5852012",
"0.58064336",
"0.5792042"... | 0.6046308 | 13 |
allows you to push an array/row to the 2 demensional array. all rows must be the same width | def << (val)
# if this is first row set the width based on size of first array to be pushed
if @h == 0
@w = val.size
elsif val.size != @w or val.class.to_s != 'Array'
raise "Only add rows/arrays the same size as the width(#{@w})"
end
@data[@h] = val
@h += 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_array(rows)\n raise ArgumentError, \"Can only work with arrays\" unless rows.is_a?(Array)\n if self.labels.size > 1 and rows.dimensions == 1\n self.add_item(rows)\n else\n # self.items = self.items + rows\n rows.each do |row|\n sel... | [
"0.67068654",
"0.65762824",
"0.6492256",
"0.6334116",
"0.61582327",
"0.6142815",
"0.61379886",
"0.6136306",
"0.6105991",
"0.595282",
"0.59520125",
"0.59357345",
"0.5921715",
"0.5878791",
"0.58428836",
"0.5832875",
"0.58272946",
"0.58116895",
"0.5807732",
"0.5802863",
"0.57928... | 0.72871757 | 0 |
this returns a hash of x,y | def each_index
@data.each_index do |y|
@data[y].each_index do |x|
yield x, y
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n\t\t\"#{@x}#{@y}\".hash\n\tend",
"def hash\n [group, x, y].hash\n end",
"def hash_keys\n [:x, :y]\n end",
"def hash\n @points.inject(0) { |sum, point| sum += point.x + point.y }\n end",
"def hash_code\n prime = 31\n result = 1\n result = prime * result + x... | [
"0.8494066",
"0.77073634",
"0.75714606",
"0.72874975",
"0.7216309",
"0.70593494",
"0.70473903",
"0.70212257",
"0.6825307",
"0.6825307",
"0.6825307",
"0.6825307",
"0.6825307",
"0.6825307",
"0.6825307",
"0.6822532",
"0.6785041",
"0.66861725",
"0.6421113",
"0.62906164",
"0.62667... | 0.0 | -1 |
this returns a hash of x,y,value | def each_with_index
@data.each_index do |y|
@data[y].each_with_index do |val, x|
yield x,y,val
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n\t\t\"#{@x}#{@y}\".hash\n\tend",
"def hash\n [group, x, y].hash\n end",
"def hash\n @points.inject(0) { |sum, point| sum += point.x + point.y }\n end",
"def hash_keys\n [:x, :y]\n end",
"def to_h\n { x: x, y: y }\n end",
"def to_h\n { x: ... | [
"0.7937157",
"0.7896213",
"0.7623533",
"0.74290603",
"0.71898675",
"0.7082582",
"0.6993556",
"0.6979675",
"0.6861034",
"0.6823482",
"0.6798832",
"0.6769189",
"0.66762924",
"0.65341127",
"0.65341127",
"0.65341127",
"0.65341127",
"0.65341127",
"0.65341127",
"0.65341127",
"0.653... | 0.0 | -1 |
yeilds each row of the slice from position x,y of width w and height h | def slice_rows(x,y,w,h)
(y..y+h-1).each do |i|
yield @data[i][x..x+w-1]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clip_to(x, y, w, h, &rendering_code); end",
"def slice_row inimage, rowbeg, rowend, outimage\n m_begin \"slice_row\"\n img = get_image(inimage)\n slice = img.excerpt(0, rowbeg, img.columns, rowend-rowbeg)\n put_image(outimage, slice)\n m_end \"slice_row\"\n end",
"def cut_white_space_edges\... | [
"0.60578823",
"0.60256624",
"0.6024005",
"0.6016192",
"0.580435",
"0.577119",
"0.5696392",
"0.56555814",
"0.5630477",
"0.5623385",
"0.5590841",
"0.55618393",
"0.5539382",
"0.55052227",
"0.5497365",
"0.54956174",
"0.5484765",
"0.5481666",
"0.5448207",
"0.54435617",
"0.5434807"... | 0.77835596 | 0 |
simplified version of fill that only takes one argument | def fill(x)
@data.each do |a|
a.fill x
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill(*args, &block)\n ary = self.to_a\n ary.fill *args, &block\n self.replace ary\n end",
"def fill(value)\n map! { |_| value }\n self\n end",
"def fill\n \t@fill\n end",
"def new_fill(value)\n self.class.new(*shape).fill(value)\n end",
"def fill\n retu... | [
"0.7889927",
"0.67792344",
"0.6765239",
"0.6664033",
"0.64098614",
"0.6363014",
"0.6114919",
"0.60925",
"0.5948215",
"0.5917927",
"0.58302677",
"0.57890606",
"0.5772848",
"0.5731747",
"0.5695932",
"0.55723214",
"0.55303895",
"0.5490103",
"0.54730046",
"0.5456026",
"0.544089",... | 0.7154743 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.