_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q226300 | Table.add_named_foreign_key_constraint | train | def add_named_foreign_key_constraint(
self, name, foreign_table, local_columns, foreign_columns, options
):
"""
Adds a foreign key constraint with a given name.
:param name: The constraint name
:type name: str
:param foreign_table: Table instance or table name
... | python | {
"resource": ""
} |
q226301 | Table._add_index | train | def _add_index(self, index):
"""
Adds an index to the table.
:param index: The index to add
:type index: Index
:rtype: Table
"""
index_name = index.get_name()
index_name = self._normalize_identifier(index_name)
replaced_implicit_indexes = []
... | python | {
"resource": ""
} |
q226302 | Table.has_foreign_key | train | def has_foreign_key(self, name):
"""
Returns whether this table has a foreign key constraint with the given name.
:param name: The constraint name
:type name: str
:rtype: bool
"""
name = self._normalize_identifier(name)
return name in self._fk_constrain... | python | {
"resource": ""
} |
q226303 | Table.get_foreign_key | train | def get_foreign_key(self, name):
"""
Returns the foreign key constraint with the given name.
:param name: The constraint name
:type name: str
:rtype: ForeignKeyConstraint
"""
name = self._normalize_identifier(name)
if not self.has_foreign_key(name):
... | python | {
"resource": ""
} |
q226304 | Table.remove_foreign_key | train | def remove_foreign_key(self, name):
"""
Removes the foreign key constraint with the given name.
:param name: The constraint name
:type name: str
"""
name = self._normalize_identifier(name)
if not self.has_foreign_key(name):
raise ForeignKeyDoesNotExi... | python | {
"resource": ""
} |
q226305 | Table.get_primary_key_columns | train | def get_primary_key_columns(self):
"""
Returns the primary key columns.
:rtype: list
"""
if not self.has_primary_key():
raise DBALException('Table "%s" has no primary key.' % self.get_name())
return self.get_primary_key().get_columns() | python | {
"resource": ""
} |
q226306 | Table.has_index | train | def has_index(self, name):
"""
Returns whether this table has an Index with the given name.
:param name: The index name
:type name: str
:rtype: bool
"""
name = self._normalize_identifier(name)
return name in self._indexes | python | {
"resource": ""
} |
q226307 | Table.get_index | train | def get_index(self, name):
"""
Returns the Index with the given name.
:param name: The index name
:type name: str
:rtype: Index
"""
name = self._normalize_identifier(name)
if not self.has_index(name):
raise IndexDoesNotExist(name, self._name)... | python | {
"resource": ""
} |
q226308 | Builder.without_global_scope | train | def without_global_scope(self, scope):
"""
Remove a registered global scope.
:param scope: The scope to remove
:type scope: Scope or str
:rtype: Builder
"""
if isinstance(scope, basestring):
del self._scopes[scope]
return self
k... | python | {
"resource": ""
} |
q226309 | Builder.find_or_fail | train | def find_or_fail(self, id, columns=None):
"""
Find a model by its primary key or raise an exception
:param id: The primary key value
:type id: mixed
:param columns: The columns to retrieve
:type columns: list
:return: The found model
:rtype: orator.Mode... | python | {
"resource": ""
} |
q226310 | Builder.first_or_fail | train | def first_or_fail(self, columns=None):
"""
Execute the query and get the first result or raise an exception
:param columns: The columns to get
:type columns: list
:return: The result
:rtype: mixed
"""
model = self.first(columns)
if model is not ... | python | {
"resource": ""
} |
q226311 | Builder.pluck | train | def pluck(self, column):
"""
Pluck a single column from the database.
:param column: THe column to pluck
:type column: str
:return: The column value
:rtype: mixed
"""
result = self.first([column])
if result:
return result[column] | python | {
"resource": ""
} |
q226312 | Builder._add_updated_at_column | train | def _add_updated_at_column(self, values):
"""
Add the "updated_at" column to a dictionary of values.
:param values: The values to update
:type values: dict
:return: The new dictionary of values
:rtype: dict
"""
if not self._model.uses_timestamps():
... | python | {
"resource": ""
} |
q226313 | Builder.delete | train | def delete(self):
"""
Delete a record from the database.
"""
if self._on_delete is not None:
return self._on_delete(self)
return self._query.delete() | python | {
"resource": ""
} |
q226314 | Builder.get_relation | train | def get_relation(self, relation):
"""
Get the relation instance for the given relation name.
:rtype: orator.orm.relations.Relation
"""
from .relations import Relation
with Relation.no_constraints(True):
rel = getattr(self.get_model(), relation)()
ne... | python | {
"resource": ""
} |
q226315 | Builder._nested_relations | train | def _nested_relations(self, relation):
"""
Get the deeply nested relations for a given top-level relation.
:rtype: dict
"""
nested = {}
for name, constraints in self._eager_load.items():
if self._is_nested(name, relation):
nested[name[len(rel... | python | {
"resource": ""
} |
q226316 | Builder._is_nested | train | def _is_nested(self, name, relation):
"""
Determine if the relationship is nested.
:type name: str
:type relation: str
:rtype: bool
"""
dots = name.find(".")
return dots and name.startswith(relation + ".") | python | {
"resource": ""
} |
q226317 | Builder.where_exists | train | def where_exists(self, query, boolean="and", negate=False):
"""
Add an exists clause to the query.
:param query: The exists query
:type query: Builder or QueryBuilder
:type boolean: str
:type negate: bool
:rtype: Builder
"""
if isinstance(query... | python | {
"resource": ""
} |
q226318 | Builder.has | train | def has(self, relation, operator=">=", count=1, boolean="and", extra=None):
"""
Add a relationship count condition to the query.
:param relation: The relation to count
:type relation: str
:param operator: The operator
:type operator: str
:param count: The count... | python | {
"resource": ""
} |
q226319 | Builder._add_has_where | train | def _add_has_where(self, has_query, relation, operator, count, boolean):
"""
Add the "has" condition where clause to the query.
:param has_query: The has query
:type has_query: Builder
:param relation: The relation to count
:type relation: orator.orm.relations.Relation
... | python | {
"resource": ""
} |
q226320 | Builder._merge_model_defined_relation_wheres_to_has_query | train | def _merge_model_defined_relation_wheres_to_has_query(self, has_query, relation):
"""
Merge the "wheres" from a relation query to a has query.
:param has_query: The has query
:type has_query: Builder
:param relation: The relation to count
:type relation: orator.orm.rela... | python | {
"resource": ""
} |
q226321 | Builder.apply_scopes | train | def apply_scopes(self):
"""
Get the underlying query builder instance with applied global scopes.
:type: Builder
"""
if not self._scopes:
return self
builder = copy.copy(self)
query = builder.get_query()
# We will keep track of how many whe... | python | {
"resource": ""
} |
q226322 | Builder._apply_scope | train | def _apply_scope(self, scope, builder):
"""
Apply a single scope on the given builder instance.
:param scope: The scope to apply
:type scope: callable or Scope
:param builder: The builder to apply the scope to
:type builder: Builder
"""
if callable(scope... | python | {
"resource": ""
} |
q226323 | Builder._nest_wheres_for_scope | train | def _nest_wheres_for_scope(self, query, where_counts):
"""
Nest where conditions of the builder and each global scope.
:type query: QueryBuilder
:type where_counts: list
"""
# Here, we totally remove all of the where clauses since we are going to
# rebuild them a... | python | {
"resource": ""
} |
q226324 | Builder._slice_where_conditions | train | def _slice_where_conditions(self, wheres, offset, length):
"""
Create a where list with sliced where conditions.
:type wheres: list
:type offset: int
:type length: int
:rtype: list
"""
where_group = self.get_query().for_nested_where()
where_group... | python | {
"resource": ""
} |
q226325 | Builder.set_model | train | def set_model(self, model):
"""
Set a model instance for the model being queried.
:param model: The model instance
:type model: orator.orm.Model
:return: The current Builder instance
:rtype: Builder
"""
self._model = model
self._query.from_(mode... | python | {
"resource": ""
} |
q226326 | SQLiteQueryGrammar.compile_insert | train | def compile_insert(self, query, values):
"""
Compile insert statement into SQL
:param query: A QueryBuilder instance
:type query: QueryBuilder
:param values: The insert values
:type values: dict or list
:return: The compiled insert
:rtype: str
"... | python | {
"resource": ""
} |
q226327 | SQLiteQueryGrammar.compile_truncate | train | def compile_truncate(self, query):
"""
Compile a truncate statement into SQL
:param query: A QueryBuilder instance
:type query: QueryBuilder
:return: The compiled truncate statement
:rtype: str
"""
sql = {
"DELETE FROM sqlite_sequence WHERE n... | python | {
"resource": ""
} |
q226328 | Blueprint.build | train | def build(self, connection, grammar):
"""
Execute the blueprint against the database.
:param connection: The connection to use
:type connection: orator.connections.Connection
:param grammar: The grammar to user
:type grammar: orator.query.grammars.QueryGrammar
"... | python | {
"resource": ""
} |
q226329 | Blueprint.to_sql | train | def to_sql(self, connection, grammar):
"""
Get the raw SQL statements for the blueprint.
:param connection: The connection to use
:type connection: orator.connections.Connection
:param grammar: The grammar to user
:type grammar: orator.schema.grammars.SchemaGrammar
... | python | {
"resource": ""
} |
q226330 | Blueprint._add_implied_commands | train | def _add_implied_commands(self):
"""
Add the commands that are implied by the blueprint.
"""
if len(self.get_added_columns()) and not self._creating():
self._commands.insert(0, self._create_command("add"))
if len(self.get_changed_columns()) and not self._creating():
... | python | {
"resource": ""
} |
q226331 | Blueprint.drop_column | train | def drop_column(self, *columns):
"""
Indicates that the given columns should be dropped.
:param columns: The columns to drop
:type columns: tuple
:rtype: Fluent
"""
columns = list(columns)
return self._add_command("drop_column", columns=columns) | python | {
"resource": ""
} |
q226332 | Blueprint.integer | train | def integer(self, column, auto_increment=False, unsigned=False):
"""
Create a new integer column on the table.
:param column: The column
:type column: str
:type auto_increment: bool
:type unsigned: bool
:rtype: Fluent
"""
return self._add_colum... | python | {
"resource": ""
} |
q226333 | Blueprint.small_integer | train | def small_integer(self, column, auto_increment=False, unsigned=False):
"""
Create a new small integer column on the table.
:param column: The column
:type column: str
:type auto_increment: bool
:type unsigned: bool
:rtype: Fluent
"""
return sel... | python | {
"resource": ""
} |
q226334 | Blueprint.unsigned_integer | train | def unsigned_integer(self, column, auto_increment=False):
"""
Create a new unisgned integer column on the table.
:param column: The column
:type column: str
:type auto_increment: bool
:rtype: Fluent
"""
return self.integer(column, auto_increment, True) | python | {
"resource": ""
} |
q226335 | Blueprint.unsigned_big_integer | train | def unsigned_big_integer(self, column, auto_increment=False):
"""
Create a new unsigned big integer column on the table.
:param column: The column
:type column: str
:type auto_increment: bool
:rtype: Fluent
"""
return self.big_integer(column, auto_incre... | python | {
"resource": ""
} |
q226336 | Blueprint.float | train | def float(self, column, total=8, places=2):
"""
Create a new float column on the table.
:param column: The column
:type column: str
:type total: int
:type places: 2
:rtype: Fluent
"""
return self._add_column("float", column, total=total, places... | python | {
"resource": ""
} |
q226337 | Blueprint.double | train | def double(self, column, total=None, places=None):
"""
Create a new double column on the table.
:param column: The column
:type column: str
:type total: int
:type places: 2
:rtype: Fluent
"""
return self._add_column("double", column, total=tota... | python | {
"resource": ""
} |
q226338 | Blueprint.decimal | train | def decimal(self, column, total=8, places=2):
"""
Create a new decimal column on the table.
:param column: The column
:type column: str
:type total: int
:type places: 2
:rtype: Fluent
"""
return self._add_column("decimal", column, total=total, ... | python | {
"resource": ""
} |
q226339 | Blueprint.timestamps | train | def timestamps(self, use_current=True):
"""
Create creation and update timestamps to the table.
:rtype: Fluent
"""
if use_current:
self.timestamp("created_at").use_current()
self.timestamp("updated_at").use_current()
else:
self.timesta... | python | {
"resource": ""
} |
q226340 | Blueprint.morphs | train | def morphs(self, name, index_name=None):
"""
Add the proper columns for a polymorphic table.
:type name: str
:type index_name: str
"""
self.unsigned_integer("%s_id" % name)
self.string("%s_type" % name)
self.index(["%s_id" % name, "%s_type" % name], inde... | python | {
"resource": ""
} |
q226341 | Blueprint._drop_index_command | train | def _drop_index_command(self, command, type, index):
"""
Create a new drop index command on the blueprint.
:param command: The command
:type command: str
:param type: The index type
:type type: str
:param index: The index name
:type index: str
... | python | {
"resource": ""
} |
q226342 | Blueprint._index_command | train | def _index_command(self, type, columns, index):
"""
Add a new index command to the blueprint.
:param type: The index type
:type type: str
:param columns: The index columns
:type columns: list or str
:param index: The index name
:type index: str
... | python | {
"resource": ""
} |
q226343 | Blueprint._remove_column | train | def _remove_column(self, name):
"""
Removes a column from the blueprint.
:param name: The column name
:type name: str
:rtype: Blueprint
"""
self._columns = filter(lambda c: c.name != name, self._columns)
return self | python | {
"resource": ""
} |
q226344 | Blueprint._add_command | train | def _add_command(self, name, **parameters):
"""
Add a new command to the blueprint.
:param name: The command name
:type name: str
:param parameters: The command parameters
:type parameters: dict
:rtype: Fluent
"""
command = self._create_command(... | python | {
"resource": ""
} |
q226345 | Index.get_quoted_columns | train | def get_quoted_columns(self, platform):
"""
Returns the quoted representation of the column names
the constraint is associated with.
But only if they were defined with one or a column name
is a keyword reserved by the platform.
Otherwise the plain unquoted value as inser... | python | {
"resource": ""
} |
q226346 | Index.spans_columns | train | def spans_columns(self, column_names):
"""
Checks if this index exactly spans the given column names in the correct order.
:type column_names: list
:rtype: bool
"""
columns = self.get_columns()
number_of_columns = len(columns)
same_columns = True
... | python | {
"resource": ""
} |
q226347 | Index.is_fullfilled_by | train | def is_fullfilled_by(self, other):
"""
Checks if the other index already fulfills
all the indexing and constraint needs of the current one.
:param other: The other index
:type other: Index
:rtype: bool
"""
# allow the other index to be equally large only... | python | {
"resource": ""
} |
q226348 | Index.same_partial_index | train | def same_partial_index(self, other):
"""
Return whether the two indexes have the same partial index
:param other: The other index
:type other: Index
:rtype: bool
"""
if (
self.has_option("where")
and other.has_option("where")
... | python | {
"resource": ""
} |
q226349 | Index.overrules | train | def overrules(self, other):
"""
Detects if the other index is a non-unique, non primary index
that can be overwritten by this one.
:param other: The other index
:type other: Index
:rtype: bool
"""
if other.is_primary():
return False
e... | python | {
"resource": ""
} |
q226350 | Index.remove_flag | train | def remove_flag(self, flag):
"""
Removes a flag.
:type flag: str
"""
if self.has_flag(flag):
del self._flags[flag.lower()] | python | {
"resource": ""
} |
q226351 | MySQLSchemaGrammar._compile_create_encoding | train | def _compile_create_encoding(self, sql, connection, blueprint):
"""
Append the character set specifications to a command.
:type sql: str
:type connection: orator.connections.Connection
:type blueprint: Blueprint
:rtype: str
"""
charset = blueprint.charse... | python | {
"resource": ""
} |
q226352 | SeedCommand._get_path | train | def _get_path(self, name):
"""
Get the destination class path.
:param name: The name
:type name: str
:rtype: str
"""
path = self.option("path")
if path is None:
path = self._get_seeders_path()
return os.path.join(path, "%s.py" % name... | python | {
"resource": ""
} |
q226353 | HasOneOrMany.update | train | def update(self, _attributes=None, **attributes):
"""
Perform an update on all the related models.
:param attributes: The attributes
:type attributes: dict
:rtype: int
"""
if _attributes is not None:
attributes.update(_attributes)
if self._r... | python | {
"resource": ""
} |
q226354 | URL.get_dialect | train | def get_dialect(self):
"""Return the SQLAlchemy database dialect class corresponding
to this URL's driver name.
"""
if "+" not in self.drivername:
name = self.drivername
else:
name = self.drivername.replace("+", ".")
cls = registry.load(name)
... | python | {
"resource": ""
} |
q226355 | URL.translate_connect_args | train | def translate_connect_args(self, names=[], **kw):
"""Translate url attributes into a dictionary of connection arguments.
Returns attributes of this url (`host`, `database`, `username`,
`password`, `port`) as a plain dictionary. The attribute names are
used as the keys by default. Unse... | python | {
"resource": ""
} |
q226356 | Platform.get_check_declaration_sql | train | def get_check_declaration_sql(self, definition):
"""
Obtains DBMS specific SQL code portion needed to set a CHECK constraint
declaration to be used in statements like CREATE TABLE.
:param definition: The check definition
:type definition: dict
:return: DBMS specific SQL... | python | {
"resource": ""
} |
q226357 | Platform.get_unique_constraint_declaration_sql | train | def get_unique_constraint_declaration_sql(self, name, index):
"""
Obtains DBMS specific SQL code portion needed to set a unique
constraint declaration to be used in statements like CREATE TABLE.
:param name: The name of the unique constraint.
:type name: str
:param inde... | python | {
"resource": ""
} |
q226358 | Platform.get_foreign_key_declaration_sql | train | def get_foreign_key_declaration_sql(self, foreign_key):
"""
Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint
of a field declaration to be used in statements like CREATE TABLE.
:param foreign_key: The foreign key
:type foreign_key: ForeignKeyConstrai... | python | {
"resource": ""
} |
q226359 | Platform.get_advanced_foreign_key_options_sql | train | def get_advanced_foreign_key_options_sql(self, foreign_key):
"""
Returns the FOREIGN KEY query section dealing with non-standard options
as MATCH, INITIALLY DEFERRED, ON UPDATE, ...
:param foreign_key: The foreign key
:type foreign_key: ForeignKeyConstraint
:rtype: str
... | python | {
"resource": ""
} |
q226360 | Platform.get_foreign_key_referential_action_sql | train | def get_foreign_key_referential_action_sql(self, action):
"""
Returns the given referential action in uppercase if valid, otherwise throws an exception.
:param action: The action
:type action: str
:rtype: str
"""
action = action.upper()
if action not in ... | python | {
"resource": ""
} |
q226361 | Platform.get_foreign_key_base_declaration_sql | train | def get_foreign_key_base_declaration_sql(self, foreign_key):
"""
Obtains DBMS specific SQL code portion needed to set the FOREIGN KEY constraint
of a field declaration to be used in statements like CREATE TABLE.
:param foreign_key: The foreign key
:type foreign_key: ForeignKeyCo... | python | {
"resource": ""
} |
q226362 | Platform.get_column_declaration_list_sql | train | def get_column_declaration_list_sql(self, fields):
"""
Gets declaration of a number of fields in bulk.
"""
query_fields = []
for name, field in fields.items():
query_fields.append(self.get_column_declaration_sql(name, field))
return ", ".join(query_fields) | python | {
"resource": ""
} |
q226363 | Platform.get_create_index_sql | train | def get_create_index_sql(self, index, table):
"""
Returns the SQL to create an index on a table on this platform.
:param index: The index
:type index: Index
:param table: The table
:type table: Table or str
:rtype: str
"""
if isinstance(table, T... | python | {
"resource": ""
} |
q226364 | Platform.get_create_primary_key_sql | train | def get_create_primary_key_sql(self, index, table):
"""
Returns the SQL to create an unnamed primary key constraint.
:param index: The index
:type index: Index
:param table: The table
:type table: Table or str
:rtype: str
"""
return "ALTER TABLE... | python | {
"resource": ""
} |
q226365 | Platform.get_create_foreign_key_sql | train | def get_create_foreign_key_sql(self, foreign_key, table):
"""
Returns the SQL to create a new foreign key.
:rtype: sql
"""
if isinstance(table, Table):
table = table.get_quoted_name(self)
query = "ALTER TABLE %s ADD %s" % (
table,
sel... | python | {
"resource": ""
} |
q226366 | Platform.get_drop_table_sql | train | def get_drop_table_sql(self, table):
"""
Returns the SQL snippet to drop an existing table.
:param table: The table
:type table: Table or str
:rtype: str
"""
if isinstance(table, Table):
table = table.get_quoted_name(self)
return "DROP TABLE... | python | {
"resource": ""
} |
q226367 | Platform.get_drop_index_sql | train | def get_drop_index_sql(self, index, table=None):
"""
Returns the SQL to drop an index from a table.
:param index: The index
:type index: Index or str
:param table: The table
:type table: Table or str or None
:rtype: str
"""
if isinstance(index, ... | python | {
"resource": ""
} |
q226368 | Platform._get_create_table_sql | train | def _get_create_table_sql(self, table_name, columns, options=None):
"""
Returns the SQL used to create a table.
:param table_name: The name of the table to create
:type table_name: str
:param columns: The table columns
:type columns: dict
:param options: The op... | python | {
"resource": ""
} |
q226369 | Platform.quote_identifier | train | def quote_identifier(self, string):
"""
Quotes a string so that it can be safely used as a table or column name,
even if it is a reserved word of the platform. This also detects identifier
chains separated by dot and quotes them independently.
:param string: The identifier name ... | python | {
"resource": ""
} |
q226370 | Connector._detect_database_platform | train | def _detect_database_platform(self):
"""
Detects and sets the database platform.
Evaluates custom platform class and version in order to set the correct platform.
:raises InvalidPlatformSpecified: if an invalid platform was specified for this connection.
"""
version = s... | python | {
"resource": ""
} |
q226371 | Paginator._check_for_more_pages | train | def _check_for_more_pages(self):
"""
Check for more pages. The last item will be sliced off.
"""
self._has_more = len(self._items) > self.per_page
self._items = self._items[0 : self.per_page] | python | {
"resource": ""
} |
q226372 | Comparator.diff_index | train | def diff_index(self, index1, index2):
"""
Finds the difference between the indexes index1 and index2.
Compares index1 with index2 and returns True if there are any
differences or False in case there are no differences.
:type index1: Index
:type index2: Index
:r... | python | {
"resource": ""
} |
q226373 | Seeder.call | train | def call(self, klass):
"""
Seed the given connection from the given class.
:param klass: The Seeder class
:type klass: class
"""
self._resolve(klass).run()
if self._command:
self._command.line("<info>Seeded:</info> <fg=cyan>%s</>" % klass.__name__) | python | {
"resource": ""
} |
q226374 | Seeder._resolve | train | def _resolve(self, klass):
"""
Resolve an instance of the given seeder klass.
:param klass: The Seeder class
:type klass: class
"""
resolver = None
if self._resolver:
resolver = self._resolver
elif self._command:
resolver = self._... | python | {
"resource": ""
} |
q226375 | QueryBuilder.select | train | def select(self, *columns):
"""
Set the columns to be selected
:param columns: The columns to be selected
:type columns: tuple
:return: The current QueryBuilder instance
:rtype: QueryBuilder
"""
if not columns:
columns = ["*"]
self.c... | python | {
"resource": ""
} |
q226376 | QueryBuilder.select_raw | train | def select_raw(self, expression, bindings=None):
"""
Add a new raw select expression to the query
:param expression: The raw expression
:type expression: str
:param bindings: The expression bindings
:type bindings: list
:return: The current QueryBuilder instanc... | python | {
"resource": ""
} |
q226377 | QueryBuilder.select_sub | train | def select_sub(self, query, as_):
"""
Add a subselect expression to the query
:param query: A QueryBuilder instance
:type query: QueryBuilder
:param as_: The subselect alias
:type as_: str
:return: The current QueryBuilder instance
:rtype: QueryBuilder
... | python | {
"resource": ""
} |
q226378 | QueryBuilder.add_select | train | def add_select(self, *column):
"""
Add a new select column to query
:param column: The column to add
:type column: str
:return: The current QueryBuilder instance
:rtype: QueryBuilder
"""
if not column:
column = []
self.columns += lis... | python | {
"resource": ""
} |
q226379 | QueryBuilder.left_join_where | train | def left_join_where(self, table, one, operator, two):
"""
Add a "left join where" clause to the query
:param table: The table to join with, can also be a JoinClause instance
:type table: str or JoinClause
:param one: The first column of the join condition
:type one: str... | python | {
"resource": ""
} |
q226380 | QueryBuilder.right_join | train | def right_join(self, table, one=None, operator=None, two=None):
"""
Add a right join to the query
:param table: The table to join with, can also be a JoinClause instance
:type table: str or JoinClause
:param one: The first column of the join condition
:type one: str
... | python | {
"resource": ""
} |
q226381 | QueryBuilder.right_join_where | train | def right_join_where(self, table, one, operator, two):
"""
Add a "right join where" clause to the query
:param table: The table to join with, can also be a JoinClause instance
:type table: str or JoinClause
:param one: The first column of the join condition
:type one: s... | python | {
"resource": ""
} |
q226382 | QueryBuilder.group_by | train | def group_by(self, *columns):
"""
Add a "group by" clause to the query
:param columns: The columns to group by
:type columns: tuple
:return: The current QueryBuilder instance
:rtype: QueryBuilder
"""
for column in columns:
self.groups.append(... | python | {
"resource": ""
} |
q226383 | QueryBuilder.having_raw | train | def having_raw(self, sql, bindings=None, boolean="and"):
"""
Add a raw having clause to the query
:param sql: The raw query
:type sql: str
:param bindings: The query bindings
:type bindings: list
:param boolean: Boolean joiner type
:type boolean: str
... | python | {
"resource": ""
} |
q226384 | QueryBuilder.order_by | train | def order_by(self, column, direction="asc"):
"""
Add a "order by" clause to the query
:param column: The order by column
:type column: str
:param direction: The direction of the order
:type direction: str
:return: The current QueryBuilder instance
:rtyp... | python | {
"resource": ""
} |
q226385 | QueryBuilder.order_by_raw | train | def order_by_raw(self, sql, bindings=None):
"""
Add a raw "order by" clause to the query
:param sql: The raw clause
:type sql: str
:param bindings: The bdings
:param bindings: list
:return: The current QueryBuilder instance
:rtype: QueryBuilder
... | python | {
"resource": ""
} |
q226386 | QueryBuilder.get | train | def get(self, columns=None):
"""
Execute the query as a "select" statement
:param columns: The columns to get
:type columns: list
:return: The result
:rtype: Collection
"""
if not columns:
columns = ["*"]
original = self.columns
... | python | {
"resource": ""
} |
q226387 | QueryBuilder._run_select | train | def _run_select(self):
"""
Run the query as a "select" statement against the connection.
:return: The result
:rtype: list
"""
return self._connection.select(
self.to_sql(), self.get_bindings(), not self._use_write_connection
) | python | {
"resource": ""
} |
q226388 | QueryBuilder.exists | train | def exists(self):
"""
Determine if any rows exist for the current query.
:return: Whether the rows exist or not
:rtype: bool
"""
limit = self.limit_
result = self.limit(1).count() > 0
self.limit(limit)
return result | python | {
"resource": ""
} |
q226389 | QueryBuilder.count | train | def count(self, *columns):
"""
Retrieve the "count" result of the query
:param columns: The columns to get
:type columns: tuple
:return: The count
:rtype: int
"""
if not columns and self.distinct_:
columns = self.columns
if not colum... | python | {
"resource": ""
} |
q226390 | QueryBuilder.aggregate | train | def aggregate(self, func, *columns):
"""
Execute an aggregate function against the database
:param func: The aggregate function
:type func: str
:param columns: The columns to execute the fnction for
:type columns: tuple
:return: The aggregate result
:rt... | python | {
"resource": ""
} |
q226391 | QueryBuilder.insert | train | def insert(self, _values=None, **values):
"""
Insert a new record into the database
:param _values: The new record values
:type _values: dict or list
:param values: The new record values as keyword arguments
:type values: dict
:return: The result
:rtype... | python | {
"resource": ""
} |
q226392 | QueryBuilder.insert_get_id | train | def insert_get_id(self, values, sequence=None):
"""
Insert a new record and get the value of the primary key
:param values: The new record values
:type values: dict
:param sequence: The name of the primary key
:type sequence: str
:return: The value of the prima... | python | {
"resource": ""
} |
q226393 | QueryBuilder.truncate | train | def truncate(self):
"""
Run a truncate statement on the table
:rtype: None
"""
for sql, bindings in self._grammar.compile_truncate(self).items():
self._connection.statement(sql, bindings) | python | {
"resource": ""
} |
q226394 | QueryBuilder._clean_bindings | train | def _clean_bindings(self, bindings):
"""
Remove all of the expressions from bindings
:param bindings: The bindings to clean
:type bindings: list
:return: The cleaned bindings
:rtype: list
"""
return list(filter(lambda b: not isinstance(b, QueryExpression... | python | {
"resource": ""
} |
q226395 | QueryBuilder.merge | train | def merge(self, query):
"""
Merge current query with another.
:param query: The query to merge with
:type query: QueryBuilder
"""
self.columns += query.columns
self.joins += query.joins
self.wheres += query.wheres
self.groups += query.groups
... | python | {
"resource": ""
} |
q226396 | AbstractAsset._set_name | train | def _set_name(self, name):
"""
Sets the name of this asset.
:param name: The name of the asset
:type name: str
"""
if self._is_identifier_quoted(name):
self._quoted = True
name = self._trim_quotes(name)
if "." in name:
parts =... | python | {
"resource": ""
} |
q226397 | AbstractAsset._generate_identifier_name | train | def _generate_identifier_name(self, columns, prefix="", max_size=30):
"""
Generates an identifier from a list of column names obeying a certain string length.
"""
hash = ""
for column in columns:
hash += "%x" % binascii.crc32(encode(str(column)))
return (pref... | python | {
"resource": ""
} |
q226398 | SoftDeletes.only_trashed | train | def only_trashed(cls):
"""
Get a new query builder that only includes soft deletes
:type cls: orator.orm.model.Model
:rtype: orator.orm.builder.Builder
"""
instance = cls()
column = instance.get_qualified_deleted_at_column()
return instance.new_query_w... | python | {
"resource": ""
} |
q226399 | BaseDatabaseManager.connection | train | def connection(self, name=None):
"""
Get a database connection instance
:param name: The connection name
:type name: str
:return: A Connection instance
:rtype: orator.connections.connection.Connection
"""
name, type = self._parse_connection_name(name)
... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.