id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
231,000
sdispater/orator
orator/schema/blueprint.py
Blueprint.morphs
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
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...
[ "def", "morphs", "(", "self", ",", "name", ",", "index_name", "=", "None", ")", ":", "self", ".", "unsigned_integer", "(", "\"%s_id\"", "%", "name", ")", "self", ".", "string", "(", "\"%s_type\"", "%", "name", ")", "self", ".", "index", "(", "[", "\"...
Add the proper columns for a polymorphic table. :type name: str :type index_name: str
[ "Add", "the", "proper", "columns", "for", "a", "polymorphic", "table", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L634-L644
231,001
sdispater/orator
orator/schema/blueprint.py
Blueprint._drop_index_command
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
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 ...
[ "def", "_drop_index_command", "(", "self", ",", "command", ",", "type", ",", "index", ")", ":", "columns", "=", "[", "]", "if", "isinstance", "(", "index", ",", "list", ")", ":", "columns", "=", "index", "index", "=", "self", ".", "_create_index_name", ...
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 :rtype: Fluent
[ "Create", "a", "new", "drop", "index", "command", "on", "the", "blueprint", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L646-L668
231,002
sdispater/orator
orator/schema/blueprint.py
Blueprint._index_command
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
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 ...
[ "def", "_index_command", "(", "self", ",", "type", ",", "columns", ",", "index", ")", ":", "if", "not", "isinstance", "(", "columns", ",", "list", ")", ":", "columns", "=", "[", "columns", "]", "if", "not", "index", ":", "index", "=", "self", ".", ...
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 :rtype: Fluent
[ "Add", "a", "new", "index", "command", "to", "the", "blueprint", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L670-L691
231,003
sdispater/orator
orator/schema/blueprint.py
Blueprint._remove_column
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
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
[ "def", "_remove_column", "(", "self", ",", "name", ")", ":", "self", ".", "_columns", "=", "filter", "(", "lambda", "c", ":", "c", ".", "name", "!=", "name", ",", "self", ".", "_columns", ")", "return", "self" ]
Removes a column from the blueprint. :param name: The column name :type name: str :rtype: Blueprint
[ "Removes", "a", "column", "from", "the", "blueprint", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L727-L738
231,004
sdispater/orator
orator/schema/blueprint.py
Blueprint._add_command
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
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(...
[ "def", "_add_command", "(", "self", ",", "name", ",", "*", "*", "parameters", ")", ":", "command", "=", "self", ".", "_create_command", "(", "name", ",", "*", "*", "parameters", ")", "self", ".", "_commands", ".", "append", "(", "command", ")", "return...
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
[ "Add", "a", "new", "command", "to", "the", "blueprint", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L740-L755
231,005
sdispater/orator
orator/dbal/index.py
Index.get_quoted_columns
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
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...
[ "def", "get_quoted_columns", "(", "self", ",", "platform", ")", ":", "columns", "=", "[", "]", "for", "column", "in", "self", ".", "_columns", ".", "values", "(", ")", ":", "columns", ".", "append", "(", "column", ".", "get_quoted_name", "(", "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 inserted is returned. :param platform: The platform to u...
[ "Returns", "the", "quoted", "representation", "of", "the", "column", "names", "the", "constraint", "is", "associated", "with", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/index.py#L65-L84
231,006
sdispater/orator
orator/dbal/index.py
Index.spans_columns
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
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 ...
[ "def", "spans_columns", "(", "self", ",", "column_names", ")", ":", "columns", "=", "self", ".", "get_columns", "(", ")", "number_of_columns", "=", "len", "(", "columns", ")", "same_columns", "=", "True", "for", "i", "in", "range", "(", "number_of_columns", ...
Checks if this index exactly spans the given column names in the correct order. :type column_names: list :rtype: bool
[ "Checks", "if", "this", "index", "exactly", "spans", "the", "given", "column", "names", "in", "the", "correct", "order", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/index.py#L115-L134
231,007
sdispater/orator
orator/dbal/index.py
Index.is_fullfilled_by
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
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...
[ "def", "is_fullfilled_by", "(", "self", ",", "other", ")", ":", "# allow the other index to be equally large only. It being larger is an option", "# but it creates a problem with scenarios of the kind PRIMARY KEY(foo,bar) UNIQUE(foo)", "if", "len", "(", "other", ".", "get_columns", "...
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
[ "Checks", "if", "the", "other", "index", "already", "fulfills", "all", "the", "indexing", "and", "constraint", "needs", "of", "the", "current", "one", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/index.py#L136-L172
231,008
sdispater/orator
orator/dbal/index.py
Index.same_partial_index
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
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") ...
[ "def", "same_partial_index", "(", "self", ",", "other", ")", ":", "if", "(", "self", ".", "has_option", "(", "\"where\"", ")", "and", "other", ".", "has_option", "(", "\"where\"", ")", "and", "self", ".", "get_option", "(", "\"where\"", ")", "==", "other...
Return whether the two indexes have the same partial index :param other: The other index :type other: Index :rtype: bool
[ "Return", "whether", "the", "two", "indexes", "have", "the", "same", "partial", "index" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/index.py#L174-L193
231,009
sdispater/orator
orator/dbal/index.py
Index.overrules
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
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...
[ "def", "overrules", "(", "self", ",", "other", ")", ":", "if", "other", ".", "is_primary", "(", ")", ":", "return", "False", "elif", "self", ".", "is_simple_index", "(", ")", "and", "other", ".", "is_unique", "(", ")", ":", "return", "False", "same_col...
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
[ "Detects", "if", "the", "other", "index", "is", "a", "non", "-", "unique", "non", "primary", "index", "that", "can", "be", "overwritten", "by", "this", "one", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/index.py#L195-L218
231,010
sdispater/orator
orator/dbal/index.py
Index.remove_flag
def remove_flag(self, flag): """ Removes a flag. :type flag: str """ if self.has_flag(flag): del self._flags[flag.lower()]
python
def remove_flag(self, flag): """ Removes a flag. :type flag: str """ if self.has_flag(flag): del self._flags[flag.lower()]
[ "def", "remove_flag", "(", "self", ",", "flag", ")", ":", "if", "self", ".", "has_flag", "(", "flag", ")", ":", "del", "self", ".", "_flags", "[", "flag", ".", "lower", "(", ")", "]" ]
Removes a flag. :type flag: str
[ "Removes", "a", "flag", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/index.py#L252-L259
231,011
sdispater/orator
orator/schema/grammars/mysql_grammar.py
MySQLSchemaGrammar._compile_create_encoding
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
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...
[ "def", "_compile_create_encoding", "(", "self", ",", "sql", ",", "connection", ",", "blueprint", ")", ":", "charset", "=", "blueprint", ".", "charset", "or", "connection", ".", "get_config", "(", "\"charset\"", ")", "if", "charset", ":", "sql", "+=", "\" DEF...
Append the character set specifications to a command. :type sql: str :type connection: orator.connections.Connection :type blueprint: Blueprint :rtype: str
[ "Append", "the", "character", "set", "specifications", "to", "a", "command", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/grammars/mysql_grammar.py#L71-L89
231,012
sdispater/orator
orator/commands/seeds/seed_command.py
SeedCommand._get_path
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
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...
[ "def", "_get_path", "(", "self", ",", "name", ")", ":", "path", "=", "self", ".", "option", "(", "\"path\"", ")", "if", "path", "is", "None", ":", "path", "=", "self", ".", "_get_seeders_path", "(", ")", "return", "os", ".", "path", ".", "join", "(...
Get the destination class path. :param name: The name :type name: str :rtype: str
[ "Get", "the", "destination", "class", "path", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/commands/seeds/seed_command.py#L63-L76
231,013
sdispater/orator
orator/orm/relations/has_one_or_many.py
HasOneOrMany.update
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
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...
[ "def", "update", "(", "self", ",", "_attributes", "=", "None", ",", "*", "*", "attributes", ")", ":", "if", "_attributes", "is", "not", "None", ":", "attributes", ".", "update", "(", "_attributes", ")", "if", "self", ".", "_related", ".", "uses_timestamp...
Perform an update on all the related models. :param attributes: The attributes :type attributes: dict :rtype: int
[ "Perform", "an", "update", "on", "all", "the", "related", "models", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/has_one_or_many.py#L297-L312
231,014
sdispater/orator
orator/utils/url.py
URL.get_dialect
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
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) ...
[ "def", "get_dialect", "(", "self", ")", ":", "if", "\"+\"", "not", "in", "self", ".", "drivername", ":", "name", "=", "self", ".", "drivername", "else", ":", "name", "=", "self", ".", "drivername", ".", "replace", "(", "\"+\"", ",", "\".\"", ")", "cl...
Return the SQLAlchemy database dialect class corresponding to this URL's driver name.
[ "Return", "the", "SQLAlchemy", "database", "dialect", "class", "corresponding", "to", "this", "URL", "s", "driver", "name", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/utils/url.py#L122-L142
231,015
sdispater/orator
orator/utils/url.py
URL.translate_connect_args
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
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...
[ "def", "translate_connect_args", "(", "self", ",", "names", "=", "[", "]", ",", "*", "*", "kw", ")", ":", "translated", "=", "{", "}", "attribute_names", "=", "[", "\"host\"", ",", "\"database\"", ",", "\"username\"", ",", "\"password\"", ",", "\"port\"", ...
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. Unset or false attributes are omitted from the final dict...
[ "Translate", "url", "attributes", "into", "a", "dictionary", "of", "connection", "arguments", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/utils/url.py#L144-L169
231,016
sdispater/orator
orator/dbal/platforms/platform.py
Platform.get_check_declaration_sql
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
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...
[ "def", "get_check_declaration_sql", "(", "self", ",", "definition", ")", ":", "constraints", "=", "[", "]", "for", "field", ",", "def_", "in", "definition", ".", "items", "(", ")", ":", "if", "isinstance", "(", "def_", ",", "basestring", ")", ":", "const...
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 code portion needed to set a CHECK constraint. :rtype: str
[ "Obtains", "DBMS", "specific", "SQL", "code", "portion", "needed", "to", "set", "a", "CHECK", "constraint", "declaration", "to", "be", "used", "in", "statements", "like", "CREATE", "TABLE", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L71-L93
231,017
sdispater/orator
orator/dbal/platforms/platform.py
Platform.get_unique_constraint_declaration_sql
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
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...
[ "def", "get_unique_constraint_declaration_sql", "(", "self", ",", "name", ",", "index", ")", ":", "columns", "=", "index", ".", "get_quoted_columns", "(", "self", ")", "name", "=", "Identifier", "(", "name", ")", "if", "not", "columns", ":", "raise", "DBALEx...
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 index: The index definition :type index: Index :return: DBMS specific...
[ "Obtains", "DBMS", "specific", "SQL", "code", "portion", "needed", "to", "set", "a", "unique", "constraint", "declaration", "to", "be", "used", "in", "statements", "like", "CREATE", "TABLE", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L95-L119
231,018
sdispater/orator
orator/dbal/platforms/platform.py
Platform.get_foreign_key_declaration_sql
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
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...
[ "def", "get_foreign_key_declaration_sql", "(", "self", ",", "foreign_key", ")", ":", "sql", "=", "self", ".", "get_foreign_key_base_declaration_sql", "(", "foreign_key", ")", "sql", "+=", "self", ".", "get_advanced_foreign_key_options_sql", "(", "foreign_key", ")", "r...
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: ForeignKeyConstraint :rtype: str
[ "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", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L148-L161
231,019
sdispater/orator
orator/dbal/platforms/platform.py
Platform.get_advanced_foreign_key_options_sql
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
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 ...
[ "def", "get_advanced_foreign_key_options_sql", "(", "self", ",", "foreign_key", ")", ":", "query", "=", "\"\"", "if", "self", ".", "supports_foreign_key_on_update", "(", ")", "and", "foreign_key", ".", "has_option", "(", "\"on_update\"", ")", ":", "query", "+=", ...
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
[ "Returns", "the", "FOREIGN", "KEY", "query", "section", "dealing", "with", "non", "-", "standard", "options", "as", "MATCH", "INITIALLY", "DEFERRED", "ON", "UPDATE", "..." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L163-L186
231,020
sdispater/orator
orator/dbal/platforms/platform.py
Platform.get_foreign_key_referential_action_sql
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
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 ...
[ "def", "get_foreign_key_referential_action_sql", "(", "self", ",", "action", ")", ":", "action", "=", "action", ".", "upper", "(", ")", "if", "action", "not", "in", "[", "\"CASCADE\"", ",", "\"SET NULL\"", ",", "\"NO ACTION\"", ",", "\"RESTRICT\"", ",", "\"SET...
Returns the given referential action in uppercase if valid, otherwise throws an exception. :param action: The action :type action: str :rtype: str
[ "Returns", "the", "given", "referential", "action", "in", "uppercase", "if", "valid", "otherwise", "throws", "an", "exception", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L188-L207
231,021
sdispater/orator
orator/dbal/platforms/platform.py
Platform.get_foreign_key_base_declaration_sql
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
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...
[ "def", "get_foreign_key_base_declaration_sql", "(", "self", ",", "foreign_key", ")", ":", "sql", "=", "\"\"", "if", "foreign_key", ".", "get_name", "(", ")", ":", "sql", "+=", "\"CONSTRAINT %s \"", "%", "foreign_key", ".", "get_quoted_name", "(", "self", ")", ...
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: ForeignKeyConstraint :rtype: str
[ "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", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L209-L240
231,022
sdispater/orator
orator/dbal/platforms/platform.py
Platform.get_column_declaration_list_sql
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
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)
[ "def", "get_column_declaration_list_sql", "(", "self", ",", "fields", ")", ":", "query_fields", "=", "[", "]", "for", "name", ",", "field", "in", "fields", ".", "items", "(", ")", ":", "query_fields", ".", "append", "(", "self", ".", "get_column_declaration_...
Gets declaration of a number of fields in bulk.
[ "Gets", "declaration", "of", "a", "number", "of", "fields", "in", "bulk", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L256-L265
231,023
sdispater/orator
orator/dbal/platforms/platform.py
Platform.get_create_index_sql
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
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...
[ "def", "get_create_index_sql", "(", "self", ",", "index", ",", "table", ")", ":", "if", "isinstance", "(", "table", ",", "Table", ")", ":", "table", "=", "table", ".", "get_quoted_name", "(", "self", ")", "name", "=", "index", ".", "get_quoted_name", "("...
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
[ "Returns", "the", "SQL", "to", "create", "an", "index", "on", "a", "table", "on", "this", "platform", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L418-L452
231,024
sdispater/orator
orator/dbal/platforms/platform.py
Platform.get_create_primary_key_sql
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
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...
[ "def", "get_create_primary_key_sql", "(", "self", ",", "index", ",", "table", ")", ":", "return", "\"ALTER TABLE %s ADD PRIMARY KEY (%s)\"", "%", "(", "table", ",", "self", ".", "get_index_field_declaration_list_sql", "(", "index", ".", "get_quoted_columns", "(", "sel...
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
[ "Returns", "the", "SQL", "to", "create", "an", "unnamed", "primary", "key", "constraint", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L482-L497
231,025
sdispater/orator
orator/dbal/platforms/platform.py
Platform.get_create_foreign_key_sql
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
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...
[ "def", "get_create_foreign_key_sql", "(", "self", ",", "foreign_key", ",", "table", ")", ":", "if", "isinstance", "(", "table", ",", "Table", ")", ":", "table", "=", "table", ".", "get_quoted_name", "(", "self", ")", "query", "=", "\"ALTER TABLE %s ADD %s\"", ...
Returns the SQL to create a new foreign key. :rtype: sql
[ "Returns", "the", "SQL", "to", "create", "a", "new", "foreign", "key", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L499-L513
231,026
sdispater/orator
orator/dbal/platforms/platform.py
Platform.get_drop_table_sql
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
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...
[ "def", "get_drop_table_sql", "(", "self", ",", "table", ")", ":", "if", "isinstance", "(", "table", ",", "Table", ")", ":", "table", "=", "table", ".", "get_quoted_name", "(", "self", ")", "return", "\"DROP TABLE %s\"", "%", "table" ]
Returns the SQL snippet to drop an existing table. :param table: The table :type table: Table or str :rtype: str
[ "Returns", "the", "SQL", "snippet", "to", "drop", "an", "existing", "table", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L515-L527
231,027
sdispater/orator
orator/dbal/platforms/platform.py
Platform.get_drop_index_sql
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
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, ...
[ "def", "get_drop_index_sql", "(", "self", ",", "index", ",", "table", "=", "None", ")", ":", "if", "isinstance", "(", "index", ",", "Index", ")", ":", "index", "=", "index", ".", "get_quoted_name", "(", "self", ")", "return", "\"DROP INDEX %s\"", "%", "i...
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
[ "Returns", "the", "SQL", "to", "drop", "an", "index", "from", "a", "table", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L529-L544
231,028
sdispater/orator
orator/dbal/platforms/platform.py
Platform._get_create_table_sql
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
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...
[ "def", "_get_create_table_sql", "(", "self", ",", "table_name", ",", "columns", ",", "options", "=", "None", ")", ":", "options", "=", "options", "or", "{", "}", "column_list_sql", "=", "self", ".", "get_column_declaration_list_sql", "(", "columns", ")", "if",...
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 options :type options: dict :rtype: str
[ "Returns", "the", "SQL", "used", "to", "create", "a", "table", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L605-L653
231,029
sdispater/orator
orator/dbal/platforms/platform.py
Platform.quote_identifier
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
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 ...
[ "def", "quote_identifier", "(", "self", ",", "string", ")", ":", "if", "\".\"", "in", "string", ":", "parts", "=", "list", "(", "map", "(", "self", ".", "quote_single_identifier", ",", "string", ".", "split", "(", "\".\"", ")", ")", ")", "return", "\"....
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 to be quoted. :type string: str :return...
[ "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", ...
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L655-L672
231,030
sdispater/orator
orator/connectors/connector.py
Connector._detect_database_platform
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
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...
[ "def", "_detect_database_platform", "(", "self", ")", ":", "version", "=", "self", ".", "_get_database_platform_version", "(", ")", "if", "version", "is", "not", "None", ":", "self", ".", "_platform", "=", "self", ".", "_create_database_platform_for_version", "(",...
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.
[ "Detects", "and", "sets", "the", "database", "platform", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/connectors/connector.py#L65-L78
231,031
sdispater/orator
orator/pagination/paginator.py
Paginator._check_for_more_pages
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
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]
[ "def", "_check_for_more_pages", "(", "self", ")", ":", "self", ".", "_has_more", "=", "len", "(", "self", ".", "_items", ")", ">", "self", ".", "per_page", "self", ".", "_items", "=", "self", ".", "_items", "[", "0", ":", "self", ".", "per_page", "]"...
Check for more pages. The last item will be sliced off.
[ "Check", "for", "more", "pages", ".", "The", "last", "item", "will", "be", "sliced", "off", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/pagination/paginator.py#L55-L61
231,032
sdispater/orator
orator/dbal/comparator.py
Comparator.diff_index
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
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...
[ "def", "diff_index", "(", "self", ",", "index1", ",", "index2", ")", ":", "if", "index1", ".", "is_fullfilled_by", "(", "index2", ")", "and", "index2", ".", "is_fullfilled_by", "(", "index1", ")", ":", "return", "False", "return", "True" ]
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 :rtype: bool
[ "Finds", "the", "difference", "between", "the", "indexes", "index1", "and", "index2", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/comparator.py#L285-L300
231,033
sdispater/orator
orator/seeds/seeder.py
Seeder.call
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
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__)
[ "def", "call", "(", "self", ",", "klass", ")", ":", "self", ".", "_resolve", "(", "klass", ")", ".", "run", "(", ")", "if", "self", ".", "_command", ":", "self", ".", "_command", ".", "line", "(", "\"<info>Seeded:</info> <fg=cyan>%s</>\"", "%", "klass", ...
Seed the given connection from the given class. :param klass: The Seeder class :type klass: class
[ "Seed", "the", "given", "connection", "from", "the", "given", "class", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/seeds/seeder.py#L25-L35
231,034
sdispater/orator
orator/seeds/seeder.py
Seeder._resolve
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
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._...
[ "def", "_resolve", "(", "self", ",", "klass", ")", ":", "resolver", "=", "None", "if", "self", ".", "_resolver", ":", "resolver", "=", "self", ".", "_resolver", "elif", "self", ".", "_command", ":", "resolver", "=", "self", ".", "_command", ".", "resol...
Resolve an instance of the given seeder klass. :param klass: The Seeder class :type klass: class
[ "Resolve", "an", "instance", "of", "the", "given", "seeder", "klass", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/seeds/seeder.py#L37-L57
231,035
sdispater/orator
orator/query/builder.py
QueryBuilder.select
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
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...
[ "def", "select", "(", "self", ",", "*", "columns", ")", ":", "if", "not", "columns", ":", "columns", "=", "[", "\"*\"", "]", "self", ".", "columns", "=", "list", "(", "columns", ")", "return", "self" ]
Set the columns to be selected :param columns: The columns to be selected :type columns: tuple :return: The current QueryBuilder instance :rtype: QueryBuilder
[ "Set", "the", "columns", "to", "be", "selected" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L90-L105
231,036
sdispater/orator
orator/query/builder.py
QueryBuilder.select_raw
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
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...
[ "def", "select_raw", "(", "self", ",", "expression", ",", "bindings", "=", "None", ")", ":", "self", ".", "add_select", "(", "QueryExpression", "(", "expression", ")", ")", "if", "bindings", ":", "self", ".", "add_binding", "(", "bindings", ",", "\"select\...
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 instance :rtype: QueryBuilder
[ "Add", "a", "new", "raw", "select", "expression", "to", "the", "query" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L107-L125
231,037
sdispater/orator
orator/query/builder.py
QueryBuilder.select_sub
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
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 ...
[ "def", "select_sub", "(", "self", ",", "query", ",", "as_", ")", ":", "if", "isinstance", "(", "query", ",", "QueryBuilder", ")", ":", "bindings", "=", "query", ".", "get_bindings", "(", ")", "query", "=", "query", ".", "to_sql", "(", ")", "elif", "i...
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
[ "Add", "a", "subselect", "expression", "to", "the", "query" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L127-L151
231,038
sdispater/orator
orator/query/builder.py
QueryBuilder.add_select
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
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...
[ "def", "add_select", "(", "self", ",", "*", "column", ")", ":", "if", "not", "column", ":", "column", "=", "[", "]", "self", ".", "columns", "+=", "list", "(", "column", ")", "return", "self" ]
Add a new select column to query :param column: The column to add :type column: str :return: The current QueryBuilder instance :rtype: QueryBuilder
[ "Add", "a", "new", "select", "column", "to", "query" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L153-L168
231,039
sdispater/orator
orator/query/builder.py
QueryBuilder.left_join_where
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
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...
[ "def", "left_join_where", "(", "self", ",", "table", ",", "one", ",", "operator", ",", "two", ")", ":", "return", "self", ".", "join_where", "(", "table", ",", "one", ",", "operator", ",", "two", ",", "\"left\"", ")" ]
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 :param operator: The operator of the join condition :typ...
[ "Add", "a", "left", "join", "where", "clause", "to", "the", "query" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L280-L299
231,040
sdispater/orator
orator/query/builder.py
QueryBuilder.right_join
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
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 ...
[ "def", "right_join", "(", "self", ",", "table", ",", "one", "=", "None", ",", "operator", "=", "None", ",", "two", "=", "None", ")", ":", "if", "isinstance", "(", "table", ",", "JoinClause", ")", ":", "table", ".", "type", "=", "\"right\"", "return",...
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 :param operator: The operator of the join condition :type operator: st...
[ "Add", "a", "right", "join", "to", "the", "query" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L301-L323
231,041
sdispater/orator
orator/query/builder.py
QueryBuilder.right_join_where
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
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...
[ "def", "right_join_where", "(", "self", ",", "table", ",", "one", ",", "operator", ",", "two", ")", ":", "return", "self", ".", "join_where", "(", "table", ",", "one", ",", "operator", ",", "two", ",", "\"right\"", ")" ]
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: str :param operator: The operator of the join condition :ty...
[ "Add", "a", "right", "join", "where", "clause", "to", "the", "query" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L325-L344
231,042
sdispater/orator
orator/query/builder.py
QueryBuilder.group_by
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
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(...
[ "def", "group_by", "(", "self", ",", "*", "columns", ")", ":", "for", "column", "in", "columns", ":", "self", ".", "groups", ".", "append", "(", "column", ")", "return", "self" ]
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
[ "Add", "a", "group", "by", "clause", "to", "the", "query" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L694-L707
231,043
sdispater/orator
orator/query/builder.py
QueryBuilder.having_raw
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
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 ...
[ "def", "having_raw", "(", "self", ",", "sql", ",", "bindings", "=", "None", ",", "boolean", "=", "\"and\"", ")", ":", "type", "=", "\"raw\"", "self", ".", "havings", ".", "append", "(", "{", "\"type\"", ":", "type", ",", "\"sql\"", ":", "sql", ",", ...
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 :return: The current QueryBuilder instance :rtype: QueryBuilde...
[ "Add", "a", "raw", "having", "clause", "to", "the", "query" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L763-L785
231,044
sdispater/orator
orator/query/builder.py
QueryBuilder.order_by
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
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...
[ "def", "order_by", "(", "self", ",", "column", ",", "direction", "=", "\"asc\"", ")", ":", "if", "self", ".", "unions", ":", "prop", "=", "\"union_orders\"", "else", ":", "prop", "=", "\"orders\"", "if", "direction", ".", "lower", "(", ")", "==", "\"as...
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 :rtype: QueryBuilder
[ "Add", "a", "order", "by", "clause", "to", "the", "query" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L802-L827
231,045
sdispater/orator
orator/query/builder.py
QueryBuilder.order_by_raw
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
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 ...
[ "def", "order_by_raw", "(", "self", ",", "sql", ",", "bindings", "=", "None", ")", ":", "if", "bindings", "is", "None", ":", "bindings", "=", "[", "]", "type", "=", "\"raw\"", "self", ".", "orders", ".", "append", "(", "{", "\"type\"", ":", "type", ...
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
[ "Add", "a", "raw", "order", "by", "clause", "to", "the", "query" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L855-L877
231,046
sdispater/orator
orator/query/builder.py
QueryBuilder.get
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
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 ...
[ "def", "get", "(", "self", ",", "columns", "=", "None", ")", ":", "if", "not", "columns", ":", "columns", "=", "[", "\"*\"", "]", "original", "=", "self", ".", "columns", "if", "not", "original", ":", "self", ".", "columns", "=", "columns", "results"...
Execute the query as a "select" statement :param columns: The columns to get :type columns: list :return: The result :rtype: Collection
[ "Execute", "the", "query", "as", "a", "select", "statement" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L1032-L1054
231,047
sdispater/orator
orator/query/builder.py
QueryBuilder._run_select
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
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 )
[ "def", "_run_select", "(", "self", ")", ":", "return", "self", ".", "_connection", ".", "select", "(", "self", ".", "to_sql", "(", ")", ",", "self", ".", "get_bindings", "(", ")", ",", "not", "self", ".", "_use_write_connection", ")" ]
Run the query as a "select" statement against the connection. :return: The result :rtype: list
[ "Run", "the", "query", "as", "a", "select", "statement", "against", "the", "connection", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L1056-L1065
231,048
sdispater/orator
orator/query/builder.py
QueryBuilder.exists
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
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
[ "def", "exists", "(", "self", ")", ":", "limit", "=", "self", ".", "limit_", "result", "=", "self", ".", "limit", "(", "1", ")", ".", "count", "(", ")", ">", "0", "self", ".", "limit", "(", "limit", ")", "return", "result" ]
Determine if any rows exist for the current query. :return: Whether the rows exist or not :rtype: bool
[ "Determine", "if", "any", "rows", "exist", "for", "the", "current", "query", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L1229-L1242
231,049
sdispater/orator
orator/query/builder.py
QueryBuilder.count
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
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...
[ "def", "count", "(", "self", ",", "*", "columns", ")", ":", "if", "not", "columns", "and", "self", ".", "distinct_", ":", "columns", "=", "self", ".", "columns", "if", "not", "columns", ":", "columns", "=", "[", "\"*\"", "]", "return", "int", "(", ...
Retrieve the "count" result of the query :param columns: The columns to get :type columns: tuple :return: The count :rtype: int
[ "Retrieve", "the", "count", "result", "of", "the", "query" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L1244-L1260
231,050
sdispater/orator
orator/query/builder.py
QueryBuilder.aggregate
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
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...
[ "def", "aggregate", "(", "self", ",", "func", ",", "*", "columns", ")", ":", "if", "not", "columns", ":", "columns", "=", "[", "\"*\"", "]", "self", ".", "aggregate_", "=", "{", "\"function\"", ":", "func", ",", "\"columns\"", ":", "columns", "}", "p...
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 :rtype: mixed
[ "Execute", "an", "aggregate", "function", "against", "the", "database" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L1314-L1341
231,051
sdispater/orator
orator/query/builder.py
QueryBuilder.insert
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
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...
[ "def", "insert", "(", "self", ",", "_values", "=", "None", ",", "*", "*", "values", ")", ":", "if", "not", "values", "and", "not", "_values", ":", "return", "True", "if", "not", "isinstance", "(", "_values", ",", "list", ")", ":", "if", "_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: bool
[ "Insert", "a", "new", "record", "into", "the", "database" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L1343-L1379
231,052
sdispater/orator
orator/query/builder.py
QueryBuilder.insert_get_id
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
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...
[ "def", "insert_get_id", "(", "self", ",", "values", ",", "sequence", "=", "None", ")", ":", "values", "=", "OrderedDict", "(", "sorted", "(", "values", ".", "items", "(", ")", ")", ")", "sql", "=", "self", ".", "_grammar", ".", "compile_insert_get_id", ...
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 primary key :rtype: int
[ "Insert", "a", "new", "record", "and", "get", "the", "value", "of", "the", "primary", "key" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L1381-L1400
231,053
sdispater/orator
orator/query/builder.py
QueryBuilder.truncate
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
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)
[ "def", "truncate", "(", "self", ")", ":", "for", "sql", ",", "bindings", "in", "self", ".", "_grammar", ".", "compile_truncate", "(", "self", ")", ".", "items", "(", ")", ":", "self", ".", "_connection", ".", "statement", "(", "sql", ",", "bindings", ...
Run a truncate statement on the table :rtype: None
[ "Run", "a", "truncate", "statement", "on", "the", "table" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L1492-L1499
231,054
sdispater/orator
orator/query/builder.py
QueryBuilder._clean_bindings
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
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...
[ "def", "_clean_bindings", "(", "self", ",", "bindings", ")", ":", "return", "list", "(", "filter", "(", "lambda", "b", ":", "not", "isinstance", "(", "b", ",", "QueryExpression", ")", ",", "bindings", ")", ")" ]
Remove all of the expressions from bindings :param bindings: The bindings to clean :type bindings: list :return: The cleaned bindings :rtype: list
[ "Remove", "all", "of", "the", "expressions", "from", "bindings" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L1525-L1535
231,055
sdispater/orator
orator/query/builder.py
QueryBuilder.merge
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
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 ...
[ "def", "merge", "(", "self", ",", "query", ")", ":", "self", ".", "columns", "+=", "query", ".", "columns", "self", ".", "joins", "+=", "query", ".", "joins", "self", ".", "wheres", "+=", "query", ".", "wheres", "self", ".", "groups", "+=", "query", ...
Merge current query with another. :param query: The query to merge with :type query: QueryBuilder
[ "Merge", "current", "query", "with", "another", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L1590-L1624
231,056
sdispater/orator
orator/dbal/abstract_asset.py
AbstractAsset._set_name
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
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 =...
[ "def", "_set_name", "(", "self", ",", "name", ")", ":", "if", "self", ".", "_is_identifier_quoted", "(", "name", ")", ":", "self", ".", "_quoted", "=", "True", "name", "=", "self", ".", "_trim_quotes", "(", "name", ")", "if", "\".\"", "in", "name", "...
Sets the name of this asset. :param name: The name of the asset :type name: str
[ "Sets", "the", "name", "of", "this", "asset", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/abstract_asset.py#L16-L32
231,057
sdispater/orator
orator/dbal/abstract_asset.py
AbstractAsset._generate_identifier_name
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
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...
[ "def", "_generate_identifier_name", "(", "self", ",", "columns", ",", "prefix", "=", "\"\"", ",", "max_size", "=", "30", ")", ":", "hash", "=", "\"\"", "for", "column", "in", "columns", ":", "hash", "+=", "\"%x\"", "%", "binascii", ".", "crc32", "(", "...
Generates an identifier from a list of column names obeying a certain string length.
[ "Generates", "an", "identifier", "from", "a", "list", "of", "column", "names", "obeying", "a", "certain", "string", "length", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/abstract_asset.py#L80-L88
231,058
sdispater/orator
orator/orm/mixins/soft_deletes.py
SoftDeletes.only_trashed
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
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...
[ "def", "only_trashed", "(", "cls", ")", ":", "instance", "=", "cls", "(", ")", "column", "=", "instance", ".", "get_qualified_deleted_at_column", "(", ")", "return", "instance", ".", "new_query_without_scope", "(", "SoftDeletingScope", "(", ")", ")", ".", "whe...
Get a new query builder that only includes soft deletes :type cls: orator.orm.model.Model :rtype: orator.orm.builder.Builder
[ "Get", "a", "new", "query", "builder", "that", "only", "includes", "soft", "deletes" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/mixins/soft_deletes.py#L92-L106
231,059
sdispater/orator
orator/database_manager.py
BaseDatabaseManager.connection
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
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) ...
[ "def", "connection", "(", "self", ",", "name", "=", "None", ")", ":", "name", ",", "type", "=", "self", ".", "_parse_connection_name", "(", "name", ")", "if", "name", "not", "in", "self", ".", "_connections", ":", "logger", ".", "debug", "(", "\"Initia...
Get a database connection instance :param name: The connection name :type name: str :return: A Connection instance :rtype: orator.connections.connection.Connection
[ "Get", "a", "database", "connection", "instance" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/database_manager.py#L28-L48
231,060
sdispater/orator
orator/orm/scopes/soft_deleting.py
SoftDeletingScope.apply
def apply(self, builder, model): """ Apply the scope to a given query builder. :param builder: The query builder :type builder: orator.orm.builder.Builder :param model: The model :type model: orator.orm.Model """ builder.where_null(model.get_qualified_de...
python
def apply(self, builder, model): """ Apply the scope to a given query builder. :param builder: The query builder :type builder: orator.orm.builder.Builder :param model: The model :type model: orator.orm.Model """ builder.where_null(model.get_qualified_de...
[ "def", "apply", "(", "self", ",", "builder", ",", "model", ")", ":", "builder", ".", "where_null", "(", "model", ".", "get_qualified_deleted_at_column", "(", ")", ")", "self", ".", "extend", "(", "builder", ")" ]
Apply the scope to a given query builder. :param builder: The query builder :type builder: orator.orm.builder.Builder :param model: The model :type model: orator.orm.Model
[ "Apply", "the", "scope", "to", "a", "given", "query", "builder", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/scopes/soft_deleting.py#L10-L22
231,061
sdispater/orator
orator/orm/scopes/soft_deleting.py
SoftDeletingScope._on_delete
def _on_delete(self, builder): """ The delete replacement function. :param builder: The query builder :type builder: orator.orm.builder.Builder """ column = self._get_deleted_at_column(builder) return builder.update({column: builder.get_model().fresh_timestamp()...
python
def _on_delete(self, builder): """ The delete replacement function. :param builder: The query builder :type builder: orator.orm.builder.Builder """ column = self._get_deleted_at_column(builder) return builder.update({column: builder.get_model().fresh_timestamp()...
[ "def", "_on_delete", "(", "self", ",", "builder", ")", ":", "column", "=", "self", ".", "_get_deleted_at_column", "(", "builder", ")", "return", "builder", ".", "update", "(", "{", "column", ":", "builder", ".", "get_model", "(", ")", ".", "fresh_timestamp...
The delete replacement function. :param builder: The query builder :type builder: orator.orm.builder.Builder
[ "The", "delete", "replacement", "function", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/scopes/soft_deleting.py#L36-L45
231,062
sdispater/orator
orator/orm/scopes/soft_deleting.py
SoftDeletingScope._get_deleted_at_column
def _get_deleted_at_column(self, builder): """ Get the "deleted at" column for the builder. :param builder: The query builder :type builder: orator.orm.builder.Builder :rtype: str """ if len(builder.get_query().joins) > 0: return builder.get_model()....
python
def _get_deleted_at_column(self, builder): """ Get the "deleted at" column for the builder. :param builder: The query builder :type builder: orator.orm.builder.Builder :rtype: str """ if len(builder.get_query().joins) > 0: return builder.get_model()....
[ "def", "_get_deleted_at_column", "(", "self", ",", "builder", ")", ":", "if", "len", "(", "builder", ".", "get_query", "(", ")", ".", "joins", ")", ">", "0", ":", "return", "builder", ".", "get_model", "(", ")", ".", "get_qualified_deleted_at_column", "(",...
Get the "deleted at" column for the builder. :param builder: The query builder :type builder: orator.orm.builder.Builder :rtype: str
[ "Get", "the", "deleted", "at", "column", "for", "the", "builder", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/scopes/soft_deleting.py#L47-L59
231,063
sdispater/orator
orator/orm/scopes/soft_deleting.py
SoftDeletingScope._restore
def _restore(self, builder): """ The restore extension. :param builder: The query builder :type builder: orator.orm.builder.Builder """ builder.with_trashed() return builder.update({builder.get_model().get_deleted_at_column(): None})
python
def _restore(self, builder): """ The restore extension. :param builder: The query builder :type builder: orator.orm.builder.Builder """ builder.with_trashed() return builder.update({builder.get_model().get_deleted_at_column(): None})
[ "def", "_restore", "(", "self", ",", "builder", ")", ":", "builder", ".", "with_trashed", "(", ")", "return", "builder", ".", "update", "(", "{", "builder", ".", "get_model", "(", ")", ".", "get_deleted_at_column", "(", ")", ":", "None", "}", ")" ]
The restore extension. :param builder: The query builder :type builder: orator.orm.builder.Builder
[ "The", "restore", "extension", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/scopes/soft_deleting.py#L88-L97
231,064
sdispater/orator
orator/schema/builder.py
SchemaBuilder.has_table
def has_table(self, table): """ Determine if the given table exists. :param table: The table :type table: str :rtype: bool """ sql = self._grammar.compile_table_exists() table = self._connection.get_table_prefix() + table return len(self._conne...
python
def has_table(self, table): """ Determine if the given table exists. :param table: The table :type table: str :rtype: bool """ sql = self._grammar.compile_table_exists() table = self._connection.get_table_prefix() + table return len(self._conne...
[ "def", "has_table", "(", "self", ",", "table", ")", ":", "sql", "=", "self", ".", "_grammar", ".", "compile_table_exists", "(", ")", "table", "=", "self", ".", "_connection", ".", "get_table_prefix", "(", ")", "+", "table", "return", "len", "(", "self", ...
Determine if the given table exists. :param table: The table :type table: str :rtype: bool
[ "Determine", "if", "the", "given", "table", "exists", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/builder.py#L16-L29
231,065
sdispater/orator
orator/schema/builder.py
SchemaBuilder.has_column
def has_column(self, table, column): """ Determine if the given table has a given column. :param table: The table :type table: str :type column: str :rtype: bool """ column = column.lower() return column in list(map(lambda x: x.lower(), self.ge...
python
def has_column(self, table, column): """ Determine if the given table has a given column. :param table: The table :type table: str :type column: str :rtype: bool """ column = column.lower() return column in list(map(lambda x: x.lower(), self.ge...
[ "def", "has_column", "(", "self", ",", "table", ",", "column", ")", ":", "column", "=", "column", ".", "lower", "(", ")", "return", "column", "in", "list", "(", "map", "(", "lambda", "x", ":", "x", ".", "lower", "(", ")", ",", "self", ".", "get_c...
Determine if the given table has a given column. :param table: The table :type table: str :type column: str :rtype: bool
[ "Determine", "if", "the", "given", "table", "has", "a", "given", "column", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/builder.py#L31-L44
231,066
sdispater/orator
orator/schema/builder.py
SchemaBuilder.table
def table(self, table): """ Modify a table on the schema. :param table: The table """ try: blueprint = self._create_blueprint(table) yield blueprint except Exception as e: raise try: self._build(blueprint) ...
python
def table(self, table): """ Modify a table on the schema. :param table: The table """ try: blueprint = self._create_blueprint(table) yield blueprint except Exception as e: raise try: self._build(blueprint) ...
[ "def", "table", "(", "self", ",", "table", ")", ":", "try", ":", "blueprint", "=", "self", ".", "_create_blueprint", "(", "table", ")", "yield", "blueprint", "except", "Exception", "as", "e", ":", "raise", "try", ":", "self", ".", "_build", "(", "bluep...
Modify a table on the schema. :param table: The table
[ "Modify", "a", "table", "on", "the", "schema", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/builder.py#L62-L78
231,067
sdispater/orator
orator/schema/builder.py
SchemaBuilder.rename
def rename(self, from_, to): """ Rename a table on the schema. """ blueprint = self._create_blueprint(from_) blueprint.rename(to) self._build(blueprint)
python
def rename(self, from_, to): """ Rename a table on the schema. """ blueprint = self._create_blueprint(from_) blueprint.rename(to) self._build(blueprint)
[ "def", "rename", "(", "self", ",", "from_", ",", "to", ")", ":", "blueprint", "=", "self", ".", "_create_blueprint", "(", "from_", ")", "blueprint", ".", "rename", "(", "to", ")", "self", ".", "_build", "(", "blueprint", ")" ]
Rename a table on the schema.
[ "Rename", "a", "table", "on", "the", "schema", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/builder.py#L129-L137
231,068
sdispater/orator
orator/commands/migrations/make_command.py
MigrateMakeCommand._write_migration
def _write_migration(self, creator, name, table, create, path): """ Write the migration file to disk. """ file_ = os.path.basename(creator.create(name, path, table, create)) return file_
python
def _write_migration(self, creator, name, table, create, path): """ Write the migration file to disk. """ file_ = os.path.basename(creator.create(name, path, table, create)) return file_
[ "def", "_write_migration", "(", "self", ",", "creator", ",", "name", ",", "table", ",", "create", ",", "path", ")", ":", "file_", "=", "os", ".", "path", ".", "basename", "(", "creator", ".", "create", "(", "name", ",", "path", ",", "table", ",", "...
Write the migration file to disk.
[ "Write", "the", "migration", "file", "to", "disk", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/commands/migrations/make_command.py#L42-L48
231,069
sdispater/orator
orator/query/grammars/mysql_grammar.py
MySQLQueryGrammar.compile_delete
def compile_delete(self, query): """ Compile a delete statement into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled update :rtype: str """ table = self.wrap_table(query.from__) if isinstance(query.where...
python
def compile_delete(self, query): """ Compile a delete statement into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled update :rtype: str """ table = self.wrap_table(query.from__) if isinstance(query.where...
[ "def", "compile_delete", "(", "self", ",", "query", ")", ":", "table", "=", "self", ".", "wrap_table", "(", "query", ".", "from__", ")", "if", "isinstance", "(", "query", ".", "wheres", ",", "list", ")", ":", "wheres", "=", "self", ".", "_compile_where...
Compile a delete statement into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled update :rtype: str
[ "Compile", "a", "delete", "statement", "into", "SQL" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/grammars/mysql_grammar.py#L103-L135
231,070
sdispater/orator
orator/commands/command.py
Command._check_config
def _check_config(self): """ Check presence of default config files. :rtype: bool """ current_path = os.path.relpath(os.getcwd()) accepted_files = ["orator.yml", "orator.py"] for accepted_file in accepted_files: config_file = os.path.join(current_pat...
python
def _check_config(self): """ Check presence of default config files. :rtype: bool """ current_path = os.path.relpath(os.getcwd()) accepted_files = ["orator.yml", "orator.py"] for accepted_file in accepted_files: config_file = os.path.join(current_pat...
[ "def", "_check_config", "(", "self", ")", ":", "current_path", "=", "os", ".", "path", ".", "relpath", "(", "os", ".", "getcwd", "(", ")", ")", "accepted_files", "=", "[", "\"orator.yml\"", ",", "\"orator.py\"", "]", "for", "accepted_file", "in", "accepted...
Check presence of default config files. :rtype: bool
[ "Check", "presence", "of", "default", "config", "files", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/commands/command.py#L72-L87
231,071
sdispater/orator
orator/commands/command.py
Command._handle_config
def _handle_config(self, config_file): """ Check and handle a config file. :param config_file: The path to the config file :type config_file: str :rtype: bool """ config = self._get_config(config_file) self.resolver = DatabaseManager( config...
python
def _handle_config(self, config_file): """ Check and handle a config file. :param config_file: The path to the config file :type config_file: str :rtype: bool """ config = self._get_config(config_file) self.resolver = DatabaseManager( config...
[ "def", "_handle_config", "(", "self", ",", "config_file", ")", ":", "config", "=", "self", ".", "_get_config", "(", "config_file", ")", "self", ".", "resolver", "=", "DatabaseManager", "(", "config", ".", "get", "(", "\"databases\"", ",", "config", ".", "g...
Check and handle a config file. :param config_file: The path to the config file :type config_file: str :rtype: bool
[ "Check", "and", "handle", "a", "config", "file", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/commands/command.py#L89-L104
231,072
sdispater/orator
orator/migrations/database_migration_repository.py
DatabaseMigrationRepository.log
def log(self, file, batch): """ Log that a migration was run. :type file: str :type batch: int """ record = {"migration": file, "batch": batch} self.table().insert(**record)
python
def log(self, file, batch): """ Log that a migration was run. :type file: str :type batch: int """ record = {"migration": file, "batch": batch} self.table().insert(**record)
[ "def", "log", "(", "self", ",", "file", ",", "batch", ")", ":", "record", "=", "{", "\"migration\"", ":", "file", ",", "\"batch\"", ":", "batch", "}", "self", ".", "table", "(", ")", ".", "insert", "(", "*", "*", "record", ")" ]
Log that a migration was run. :type file: str :type batch: int
[ "Log", "that", "a", "migration", "was", "run", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/migrations/database_migration_repository.py#L34-L43
231,073
sdispater/orator
orator/migrations/database_migration_repository.py
DatabaseMigrationRepository.create_repository
def create_repository(self): """ Create the migration repository data store. """ schema = self.get_connection().get_schema_builder() with schema.create(self._table) as table: # The migrations table is responsible for keeping track of which of the # migrat...
python
def create_repository(self): """ Create the migration repository data store. """ schema = self.get_connection().get_schema_builder() with schema.create(self._table) as table: # The migrations table is responsible for keeping track of which of the # migrat...
[ "def", "create_repository", "(", "self", ")", ":", "schema", "=", "self", ".", "get_connection", "(", ")", ".", "get_schema_builder", "(", ")", "with", "schema", ".", "create", "(", "self", ".", "_table", ")", "as", "table", ":", "# The migrations table is r...
Create the migration repository data store.
[ "Create", "the", "migration", "repository", "data", "store", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/migrations/database_migration_repository.py#L69-L80
231,074
sdispater/orator
orator/migrations/database_migration_repository.py
DatabaseMigrationRepository.repository_exists
def repository_exists(self): """ Determine if the repository exists. :rtype: bool """ schema = self.get_connection().get_schema_builder() return schema.has_table(self._table)
python
def repository_exists(self): """ Determine if the repository exists. :rtype: bool """ schema = self.get_connection().get_schema_builder() return schema.has_table(self._table)
[ "def", "repository_exists", "(", "self", ")", ":", "schema", "=", "self", ".", "get_connection", "(", ")", ".", "get_schema_builder", "(", ")", "return", "schema", ".", "has_table", "(", "self", ".", "_table", ")" ]
Determine if the repository exists. :rtype: bool
[ "Determine", "if", "the", "repository", "exists", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/migrations/database_migration_repository.py#L82-L90
231,075
sdispater/orator
orator/migrations/migration_creator.py
MigrationCreator.create
def create(self, name, path, table=None, create=False): """ Create a new migration at the given path. :param name: The name of the migration :type name: str :param path: The path of the migrations :type path: str :param table: The table name :type table: ...
python
def create(self, name, path, table=None, create=False): """ Create a new migration at the given path. :param name: The name of the migration :type name: str :param path: The path of the migrations :type path: str :param table: The table name :type table: ...
[ "def", "create", "(", "self", ",", "name", ",", "path", ",", "table", "=", "None", ",", "create", "=", "False", ")", ":", "path", "=", "self", ".", "_get_path", "(", "name", ",", "path", ")", "if", "not", "os", ".", "path", ".", "exists", "(", ...
Create a new migration at the given path. :param name: The name of the migration :type name: str :param path: The path of the migrations :type path: str :param table: The table name :type table: str :param create: Whether it's a create migration or not :t...
[ "Create", "a", "new", "migration", "at", "the", "given", "path", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/migrations/migration_creator.py#L21-L50
231,076
sdispater/orator
orator/migrations/migration_creator.py
MigrationCreator._get_stub
def _get_stub(self, table, create): """ Get the migration stub template :param table: The table name :type table: str :param create: Whether it's a create migration or not :type create: bool :rtype: str """ if table is None: return B...
python
def _get_stub(self, table, create): """ Get the migration stub template :param table: The table name :type table: str :param create: Whether it's a create migration or not :type create: bool :rtype: str """ if table is None: return B...
[ "def", "_get_stub", "(", "self", ",", "table", ",", "create", ")", ":", "if", "table", "is", "None", ":", "return", "BLANK_STUB", "else", ":", "if", "create", ":", "stub", "=", "CREATE_STUB", "else", ":", "stub", "=", "UPDATE_STUB", "return", "stub" ]
Get the migration stub template :param table: The table name :type table: str :param create: Whether it's a create migration or not :type create: bool :rtype: str
[ "Get", "the", "migration", "stub", "template" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/migrations/migration_creator.py#L52-L72
231,077
sdispater/orator
orator/dbal/foreign_key_constraint.py
ForeignKeyConstraint.get_quoted_local_columns
def get_quoted_local_columns(self, platform): """ Returns the quoted representation of the referencing table column names the foreign key constraint is associated with. But only if they were defined with one or the referencing table column name is a keyword reserved by the platf...
python
def get_quoted_local_columns(self, platform): """ Returns the quoted representation of the referencing table column names the foreign key constraint is associated with. But only if they were defined with one or the referencing table column name is a keyword reserved by the platf...
[ "def", "get_quoted_local_columns", "(", "self", ",", "platform", ")", ":", "columns", "=", "[", "]", "for", "column", "in", "self", ".", "_local_column_names", ".", "values", "(", ")", ":", "columns", ".", "append", "(", "column", ".", "get_quoted_name", "...
Returns the quoted representation of the referencing table column names the foreign key constraint is associated with. But only if they were defined with one or the referencing table column name is a keyword reserved by the platform. Otherwise the plain unquoted value as inserted is ret...
[ "Returns", "the", "quoted", "representation", "of", "the", "referencing", "table", "column", "names", "the", "foreign", "key", "constraint", "is", "associated", "with", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/foreign_key_constraint.py#L96-L115
231,078
sdispater/orator
orator/dbal/foreign_key_constraint.py
ForeignKeyConstraint.get_quoted_foreign_columns
def get_quoted_foreign_columns(self, platform): """ Returns the quoted representation of the referenced table column names the foreign key constraint is associated with. But only if they were defined with one or the referenced table column name is a keyword reserved by the platf...
python
def get_quoted_foreign_columns(self, platform): """ Returns the quoted representation of the referenced table column names the foreign key constraint is associated with. But only if they were defined with one or the referenced table column name is a keyword reserved by the platf...
[ "def", "get_quoted_foreign_columns", "(", "self", ",", "platform", ")", ":", "columns", "=", "[", "]", "for", "column", "in", "self", ".", "_foreign_column_names", ".", "values", "(", ")", ":", "columns", ".", "append", "(", "column", ".", "get_quoted_name",...
Returns the quoted representation of the referenced table column names the foreign key constraint is associated with. But only if they were defined with one or the referenced table column name is a keyword reserved by the platform. Otherwise the plain unquoted value as inserted is retur...
[ "Returns", "the", "quoted", "representation", "of", "the", "referenced", "table", "column", "names", "the", "foreign", "key", "constraint", "is", "associated", "with", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/foreign_key_constraint.py#L189-L208
231,079
sdispater/orator
orator/dbal/foreign_key_constraint.py
ForeignKeyConstraint._on_event
def _on_event(self, event): """ Returns the referential action for a given database operation on the referenced table the foreign key constraint is associated with. :param event: Name of the database operation/event to return the referential action for. :type event: str ...
python
def _on_event(self, event): """ Returns the referential action for a given database operation on the referenced table the foreign key constraint is associated with. :param event: Name of the database operation/event to return the referential action for. :type event: str ...
[ "def", "_on_event", "(", "self", ",", "event", ")", ":", "if", "self", ".", "has_option", "(", "event", ")", ":", "on_event", "=", "self", ".", "get_option", "(", "event", ")", ".", "upper", "(", ")", "if", "on_event", "not", "in", "[", "\"NO ACTION\...
Returns the referential action for a given database operation on the referenced table the foreign key constraint is associated with. :param event: Name of the database operation/event to return the referential action for. :type event: str :rtype: str or None
[ "Returns", "the", "referential", "action", "for", "a", "given", "database", "operation", "on", "the", "referenced", "table", "the", "foreign", "key", "constraint", "is", "associated", "with", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/foreign_key_constraint.py#L246-L262
231,080
sdispater/orator
orator/migrations/migrator.py
Migrator.run
def run(self, path, pretend=False): """ Run the outstanding migrations for a given path. :param path: The path :type path: str :param pretend: Whether we execute the migrations as dry-run :type pretend: bool """ self._notes = [] files = self._get...
python
def run(self, path, pretend=False): """ Run the outstanding migrations for a given path. :param path: The path :type path: str :param pretend: Whether we execute the migrations as dry-run :type pretend: bool """ self._notes = [] files = self._get...
[ "def", "run", "(", "self", ",", "path", ",", "pretend", "=", "False", ")", ":", "self", ".", "_notes", "=", "[", "]", "files", "=", "self", ".", "_get_migration_files", "(", "path", ")", "ran", "=", "self", ".", "_repository", ".", "get_ran", "(", ...
Run the outstanding migrations for a given path. :param path: The path :type path: str :param pretend: Whether we execute the migrations as dry-run :type pretend: bool
[ "Run", "the", "outstanding", "migrations", "for", "a", "given", "path", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/migrations/migrator.py#L34-L51
231,081
sdispater/orator
orator/migrations/migrator.py
Migrator.run_migration_list
def run_migration_list(self, path, migrations, pretend=False): """ Run a list of migrations. :type migrations: list :type pretend: bool """ if not migrations: self._note("<info>Nothing to migrate</info>") return batch = self._repository...
python
def run_migration_list(self, path, migrations, pretend=False): """ Run a list of migrations. :type migrations: list :type pretend: bool """ if not migrations: self._note("<info>Nothing to migrate</info>") return batch = self._repository...
[ "def", "run_migration_list", "(", "self", ",", "path", ",", "migrations", ",", "pretend", "=", "False", ")", ":", "if", "not", "migrations", ":", "self", ".", "_note", "(", "\"<info>Nothing to migrate</info>\"", ")", "return", "batch", "=", "self", ".", "_re...
Run a list of migrations. :type migrations: list :type pretend: bool
[ "Run", "a", "list", "of", "migrations", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/migrations/migrator.py#L53-L69
231,082
sdispater/orator
orator/migrations/migrator.py
Migrator.reset
def reset(self, path, pretend=False): """ Rolls all of the currently applied migrations back. :param path: The path :type path: str :param pretend: Whether we execute the migrations as dry-run :type pretend: bool :rtype: count """ self._notes = ...
python
def reset(self, path, pretend=False): """ Rolls all of the currently applied migrations back. :param path: The path :type path: str :param pretend: Whether we execute the migrations as dry-run :type pretend: bool :rtype: count """ self._notes = ...
[ "def", "reset", "(", "self", ",", "path", ",", "pretend", "=", "False", ")", ":", "self", ".", "_notes", "=", "[", "]", "migrations", "=", "sorted", "(", "self", ".", "_repository", ".", "get_ran", "(", ")", ",", "reverse", "=", "True", ")", "count...
Rolls all of the currently applied migrations back. :param path: The path :type path: str :param pretend: Whether we execute the migrations as dry-run :type pretend: bool :rtype: count
[ "Rolls", "all", "of", "the", "currently", "applied", "migrations", "back", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/migrations/migrator.py#L125-L149
231,083
sdispater/orator
orator/migrations/migrator.py
Migrator._get_migration_files
def _get_migration_files(self, path): """ Get all of the migration files in a given path. :type path: str :rtype: list """ files = glob.glob(os.path.join(path, "[0-9]*_*.py")) if not files: return [] files = list(map(lambda f: os.path.basen...
python
def _get_migration_files(self, path): """ Get all of the migration files in a given path. :type path: str :rtype: list """ files = glob.glob(os.path.join(path, "[0-9]*_*.py")) if not files: return [] files = list(map(lambda f: os.path.basen...
[ "def", "_get_migration_files", "(", "self", ",", "path", ")", ":", "files", "=", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "path", ",", "\"[0-9]*_*.py\"", ")", ")", "if", "not", "files", ":", "return", "[", "]", "files", "=", "...
Get all of the migration files in a given path. :type path: str :rtype: list
[ "Get", "all", "of", "the", "migration", "files", "in", "a", "given", "path", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/migrations/migrator.py#L175-L192
231,084
sdispater/orator
orator/query/grammars/postgres_grammar.py
PostgresQueryGrammar._compile_update_columns
def _compile_update_columns(self, values): """ Compile the columns for the update statement :param values: The columns :type values: dict :return: The compiled columns :rtype: str """ columns = [] for key, value in values.items(): co...
python
def _compile_update_columns(self, values): """ Compile the columns for the update statement :param values: The columns :type values: dict :return: The compiled columns :rtype: str """ columns = [] for key, value in values.items(): co...
[ "def", "_compile_update_columns", "(", "self", ",", "values", ")", ":", "columns", "=", "[", "]", "for", "key", ",", "value", "in", "values", ".", "items", "(", ")", ":", "columns", ".", "append", "(", "\"%s = %s\"", "%", "(", "self", ".", "wrap", "(...
Compile the columns for the update statement :param values: The columns :type values: dict :return: The compiled columns :rtype: str
[ "Compile", "the", "columns", "for", "the", "update", "statement" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/grammars/postgres_grammar.py#L74-L89
231,085
sdispater/orator
orator/query/grammars/postgres_grammar.py
PostgresQueryGrammar._compile_update_from
def _compile_update_from(self, query): """ Compile the "from" clause for an update with a join. :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled sql :rtype: str """ if not query.joins: return "" f...
python
def _compile_update_from(self, query): """ Compile the "from" clause for an update with a join. :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled sql :rtype: str """ if not query.joins: return "" f...
[ "def", "_compile_update_from", "(", "self", ",", "query", ")", ":", "if", "not", "query", ".", "joins", ":", "return", "\"\"", "froms", "=", "[", "]", "for", "join", "in", "query", ".", "joins", ":", "froms", ".", "append", "(", "self", ".", "wrap_ta...
Compile the "from" clause for an update with a join. :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled sql :rtype: str
[ "Compile", "the", "from", "clause", "for", "an", "update", "with", "a", "join", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/grammars/postgres_grammar.py#L91-L112
231,086
sdispater/orator
orator/query/grammars/postgres_grammar.py
PostgresQueryGrammar._compile_update_wheres
def _compile_update_wheres(self, query): """ Compile the additional where clauses for updates with joins. :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled sql :rtype: str """ base_where = self._compile_wheres(query) ...
python
def _compile_update_wheres(self, query): """ Compile the additional where clauses for updates with joins. :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled sql :rtype: str """ base_where = self._compile_wheres(query) ...
[ "def", "_compile_update_wheres", "(", "self", ",", "query", ")", ":", "base_where", "=", "self", ".", "_compile_wheres", "(", "query", ")", "if", "not", "query", ".", "joins", ":", "return", "base_where", "join_where", "=", "self", ".", "_compile_update_join_w...
Compile the additional where clauses for updates with joins. :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled sql :rtype: str
[ "Compile", "the", "additional", "where", "clauses", "for", "updates", "with", "joins", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/grammars/postgres_grammar.py#L114-L134
231,087
sdispater/orator
orator/query/grammars/postgres_grammar.py
PostgresQueryGrammar._compile_update_join_wheres
def _compile_update_join_wheres(self, query): """ Compile the "join" clauses for an update. :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled sql :rtype: str """ join_wheres = [] for join in query.joins: ...
python
def _compile_update_join_wheres(self, query): """ Compile the "join" clauses for an update. :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled sql :rtype: str """ join_wheres = [] for join in query.joins: ...
[ "def", "_compile_update_join_wheres", "(", "self", ",", "query", ")", ":", "join_wheres", "=", "[", "]", "for", "join", "in", "query", ".", "joins", ":", "for", "clause", "in", "join", ".", "clauses", ":", "join_wheres", ".", "append", "(", "self", ".", ...
Compile the "join" clauses for an update. :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled sql :rtype: str
[ "Compile", "the", "join", "clauses", "for", "an", "update", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/grammars/postgres_grammar.py#L136-L152
231,088
sdispater/orator
orator/query/grammars/postgres_grammar.py
PostgresQueryGrammar.compile_insert_get_id
def compile_insert_get_id(self, query, values, sequence=None): """ Compile an insert and get ID statement into SQL. :param query: A QueryBuilder instance :type query: QueryBuilder :param values: The values to insert :type values: dict :param sequence: The id se...
python
def compile_insert_get_id(self, query, values, sequence=None): """ Compile an insert and get ID statement into SQL. :param query: A QueryBuilder instance :type query: QueryBuilder :param values: The values to insert :type values: dict :param sequence: The id se...
[ "def", "compile_insert_get_id", "(", "self", ",", "query", ",", "values", ",", "sequence", "=", "None", ")", ":", "if", "sequence", "is", "None", ":", "sequence", "=", "\"id\"", "return", "\"%s RETURNING %s\"", "%", "(", "self", ".", "compile_insert", "(", ...
Compile an insert and get ID statement into SQL. :param query: A QueryBuilder instance :type query: QueryBuilder :param values: The values to insert :type values: dict :param sequence: The id sequence :type sequence: str :return: The compiled statement ...
[ "Compile", "an", "insert", "and", "get", "ID", "statement", "into", "SQL", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/grammars/postgres_grammar.py#L154-L176
231,089
sdispater/orator
orator/utils/qmarker.py
Qmarker.qmark
def qmark(cls, query): """ Convert a "qmark" query into "format" style. """ def sub_sequence(m): s = m.group(0) if s == "??": return "?" if s == "%": return "%%" else: return "%s" re...
python
def qmark(cls, query): """ Convert a "qmark" query into "format" style. """ def sub_sequence(m): s = m.group(0) if s == "??": return "?" if s == "%": return "%%" else: return "%s" re...
[ "def", "qmark", "(", "cls", ",", "query", ")", ":", "def", "sub_sequence", "(", "m", ")", ":", "s", "=", "m", ".", "group", "(", "0", ")", "if", "s", "==", "\"??\"", ":", "return", "\"?\"", "if", "s", "==", "\"%\"", ":", "return", "\"%%\"", "el...
Convert a "qmark" query into "format" style.
[ "Convert", "a", "qmark", "query", "into", "format", "style", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/utils/qmarker.py#L11-L25
231,090
sdispater/orator
orator/orm/relations/relation.py
Relation.touch
def touch(self): """ Touch all of the related models for the relationship. """ column = self.get_related().get_updated_at_column() self.raw_update({column: self.get_related().fresh_timestamp()})
python
def touch(self): """ Touch all of the related models for the relationship. """ column = self.get_related().get_updated_at_column() self.raw_update({column: self.get_related().fresh_timestamp()})
[ "def", "touch", "(", "self", ")", ":", "column", "=", "self", ".", "get_related", "(", ")", ".", "get_updated_at_column", "(", ")", "self", ".", "raw_update", "(", "{", "column", ":", "self", ".", "get_related", "(", ")", ".", "fresh_timestamp", "(", "...
Touch all of the related models for the relationship.
[ "Touch", "all", "of", "the", "related", "models", "for", "the", "relationship", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/relation.py#L77-L83
231,091
sdispater/orator
orator/orm/relations/relation.py
Relation.raw_update
def raw_update(self, attributes=None): """ Run a raw update against the base query. :type attributes: dict :rtype: int """ if attributes is None: attributes = {} if self._query is not None: return self._query.update(attributes)
python
def raw_update(self, attributes=None): """ Run a raw update against the base query. :type attributes: dict :rtype: int """ if attributes is None: attributes = {} if self._query is not None: return self._query.update(attributes)
[ "def", "raw_update", "(", "self", ",", "attributes", "=", "None", ")", ":", "if", "attributes", "is", "None", ":", "attributes", "=", "{", "}", "if", "self", ".", "_query", "is", "not", "None", ":", "return", "self", ".", "_query", ".", "update", "("...
Run a raw update against the base query. :type attributes: dict :rtype: int
[ "Run", "a", "raw", "update", "against", "the", "base", "query", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/relation.py#L85-L97
231,092
sdispater/orator
orator/orm/relations/relation.py
Relation.wrap
def wrap(self, value): """ Wrap the given value with the parent's query grammar. :rtype: str """ return self._parent.new_query().get_query().get_grammar().wrap(value)
python
def wrap(self, value): """ Wrap the given value with the parent's query grammar. :rtype: str """ return self._parent.new_query().get_query().get_grammar().wrap(value)
[ "def", "wrap", "(", "self", ",", "value", ")", ":", "return", "self", ".", "_parent", ".", "new_query", "(", ")", ".", "get_query", "(", ")", ".", "get_grammar", "(", ")", ".", "wrap", "(", "value", ")" ]
Wrap the given value with the parent's query grammar. :rtype: str
[ "Wrap", "the", "given", "value", "with", "the", "parent", "s", "query", "grammar", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/relation.py#L199-L205
231,093
awslabs/aws-cfn-template-flip
cfn_flip/__init__.py
load
def load(template): """ Try to guess the input format """ try: data = load_json(template) return data, "json" except ValueError as e: try: data = load_yaml(template) return data, "yaml" except Exception: raise e
python
def load(template): """ Try to guess the input format """ try: data = load_json(template) return data, "json" except ValueError as e: try: data = load_yaml(template) return data, "yaml" except Exception: raise e
[ "def", "load", "(", "template", ")", ":", "try", ":", "data", "=", "load_json", "(", "template", ")", "return", "data", ",", "\"json\"", "except", "ValueError", "as", "e", ":", "try", ":", "data", "=", "load_yaml", "(", "template", ")", "return", "data...
Try to guess the input format
[ "Try", "to", "guess", "the", "input", "format" ]
837576bea243e3f5efb0a20b84802371272e2d33
https://github.com/awslabs/aws-cfn-template-flip/blob/837576bea243e3f5efb0a20b84802371272e2d33/cfn_flip/__init__.py#L21-L34
231,094
awslabs/aws-cfn-template-flip
cfn_flip/__init__.py
dump_yaml
def dump_yaml(data, clean_up=False, long_form=False): """ Output some YAML """ return yaml.dump( data, Dumper=get_dumper(clean_up, long_form), default_flow_style=False, allow_unicode=True )
python
def dump_yaml(data, clean_up=False, long_form=False): """ Output some YAML """ return yaml.dump( data, Dumper=get_dumper(clean_up, long_form), default_flow_style=False, allow_unicode=True )
[ "def", "dump_yaml", "(", "data", ",", "clean_up", "=", "False", ",", "long_form", "=", "False", ")", ":", "return", "yaml", ".", "dump", "(", "data", ",", "Dumper", "=", "get_dumper", "(", "clean_up", ",", "long_form", ")", ",", "default_flow_style", "="...
Output some YAML
[ "Output", "some", "YAML" ]
837576bea243e3f5efb0a20b84802371272e2d33
https://github.com/awslabs/aws-cfn-template-flip/blob/837576bea243e3f5efb0a20b84802371272e2d33/cfn_flip/__init__.py#L37-L47
231,095
awslabs/aws-cfn-template-flip
cfn_flip/__init__.py
to_json
def to_json(template, clean_up=False): """ Assume the input is YAML and convert to JSON """ data = load_yaml(template) if clean_up: data = clean(data) return dump_json(data)
python
def to_json(template, clean_up=False): """ Assume the input is YAML and convert to JSON """ data = load_yaml(template) if clean_up: data = clean(data) return dump_json(data)
[ "def", "to_json", "(", "template", ",", "clean_up", "=", "False", ")", ":", "data", "=", "load_yaml", "(", "template", ")", "if", "clean_up", ":", "data", "=", "clean", "(", "data", ")", "return", "dump_json", "(", "data", ")" ]
Assume the input is YAML and convert to JSON
[ "Assume", "the", "input", "is", "YAML", "and", "convert", "to", "JSON" ]
837576bea243e3f5efb0a20b84802371272e2d33
https://github.com/awslabs/aws-cfn-template-flip/blob/837576bea243e3f5efb0a20b84802371272e2d33/cfn_flip/__init__.py#L50-L60
231,096
awslabs/aws-cfn-template-flip
cfn_flip/__init__.py
to_yaml
def to_yaml(template, clean_up=False, long_form=False): """ Assume the input is JSON and convert to YAML """ data = load_json(template) if clean_up: data = clean(data) return dump_yaml(data, clean_up, long_form)
python
def to_yaml(template, clean_up=False, long_form=False): """ Assume the input is JSON and convert to YAML """ data = load_json(template) if clean_up: data = clean(data) return dump_yaml(data, clean_up, long_form)
[ "def", "to_yaml", "(", "template", ",", "clean_up", "=", "False", ",", "long_form", "=", "False", ")", ":", "data", "=", "load_json", "(", "template", ")", "if", "clean_up", ":", "data", "=", "clean", "(", "data", ")", "return", "dump_yaml", "(", "data...
Assume the input is JSON and convert to YAML
[ "Assume", "the", "input", "is", "JSON", "and", "convert", "to", "YAML" ]
837576bea243e3f5efb0a20b84802371272e2d33
https://github.com/awslabs/aws-cfn-template-flip/blob/837576bea243e3f5efb0a20b84802371272e2d33/cfn_flip/__init__.py#L63-L73
231,097
awslabs/aws-cfn-template-flip
cfn_flip/__init__.py
flip
def flip(template, in_format=None, out_format=None, clean_up=False, no_flip=False, long_form=False): """ Figure out the input format and convert the data to the opposing output format """ # Do we need to figure out the input format? if not in_format: # Load the template as JSON? if ...
python
def flip(template, in_format=None, out_format=None, clean_up=False, no_flip=False, long_form=False): """ Figure out the input format and convert the data to the opposing output format """ # Do we need to figure out the input format? if not in_format: # Load the template as JSON? if ...
[ "def", "flip", "(", "template", ",", "in_format", "=", "None", ",", "out_format", "=", "None", ",", "clean_up", "=", "False", ",", "no_flip", "=", "False", ",", "long_form", "=", "False", ")", ":", "# Do we need to figure out the input format?", "if", "not", ...
Figure out the input format and convert the data to the opposing output format
[ "Figure", "out", "the", "input", "format", "and", "convert", "the", "data", "to", "the", "opposing", "output", "format" ]
837576bea243e3f5efb0a20b84802371272e2d33
https://github.com/awslabs/aws-cfn-template-flip/blob/837576bea243e3f5efb0a20b84802371272e2d33/cfn_flip/__init__.py#L76-L115
231,098
awslabs/aws-cfn-template-flip
cfn_clean/__init__.py
convert_join
def convert_join(value): """ Fix a Join ;) """ if not isinstance(value, list) or len(value) != 2: # Cowardly refuse return value sep, parts = value[0], value[1] if isinstance(parts, six.string_types): return parts if not isinstance(parts, list): # This loo...
python
def convert_join(value): """ Fix a Join ;) """ if not isinstance(value, list) or len(value) != 2: # Cowardly refuse return value sep, parts = value[0], value[1] if isinstance(parts, six.string_types): return parts if not isinstance(parts, list): # This loo...
[ "def", "convert_join", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "list", ")", "or", "len", "(", "value", ")", "!=", "2", ":", "# Cowardly refuse", "return", "value", "sep", ",", "parts", "=", "value", "[", "0", "]", ",", ...
Fix a Join ;)
[ "Fix", "a", "Join", ";", ")" ]
837576bea243e3f5efb0a20b84802371272e2d33
https://github.com/awslabs/aws-cfn-template-flip/blob/837576bea243e3f5efb0a20b84802371272e2d33/cfn_clean/__init__.py#L18-L93
231,099
awslabs/aws-cfn-template-flip
cfn_flip/yaml_dumper.py
map_representer
def map_representer(dumper, value): """ Deal with !Ref style function format and OrderedDict """ value = ODict(value.items()) if len(value.keys()) == 1: key = list(value.keys())[0] if key in CONVERTED_SUFFIXES: return fn_representer(dumper, key, value[key]) if...
python
def map_representer(dumper, value): """ Deal with !Ref style function format and OrderedDict """ value = ODict(value.items()) if len(value.keys()) == 1: key = list(value.keys())[0] if key in CONVERTED_SUFFIXES: return fn_representer(dumper, key, value[key]) if...
[ "def", "map_representer", "(", "dumper", ",", "value", ")", ":", "value", "=", "ODict", "(", "value", ".", "items", "(", ")", ")", "if", "len", "(", "value", ".", "keys", "(", ")", ")", "==", "1", ":", "key", "=", "list", "(", "value", ".", "ke...
Deal with !Ref style function format and OrderedDict
[ "Deal", "with", "!Ref", "style", "function", "format", "and", "OrderedDict" ]
837576bea243e3f5efb0a20b84802371272e2d33
https://github.com/awslabs/aws-cfn-template-flip/blob/837576bea243e3f5efb0a20b84802371272e2d33/cfn_flip/yaml_dumper.py#L84-L100