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
230,900
TheHive-Project/Cortex-Analyzers
analyzers/TorProject/tor_project.py
TorProjectClient.search_tor_node
def search_tor_node(self, ip): """Lookup an IP address to check if it is a known tor exit node. :param ip: The IP address to lookup :type ip: str :return: Data relative to the tor node. If `ip`is a tor exit node it will contain a `node` key with the hash of the node and...
python
def search_tor_node(self, ip): """Lookup an IP address to check if it is a known tor exit node. :param ip: The IP address to lookup :type ip: str :return: Data relative to the tor node. If `ip`is a tor exit node it will contain a `node` key with the hash of the node and...
[ "def", "search_tor_node", "(", "self", ",", "ip", ")", ":", "data", "=", "{", "}", "tmp", "=", "{", "}", "present", "=", "datetime", ".", "utcnow", "(", ")", ".", "replace", "(", "tzinfo", "=", "pytz", ".", "utc", ")", "for", "line", "in", "self"...
Lookup an IP address to check if it is a known tor exit node. :param ip: The IP address to lookup :type ip: str :return: Data relative to the tor node. If `ip`is a tor exit node it will contain a `node` key with the hash of the node and a `last_status` key with...
[ "Lookup", "an", "IP", "address", "to", "check", "if", "it", "is", "a", "known", "tor", "exit", "node", "." ]
8dae6a8c4cf9af5554ae8c844985c4b44d4bd4bf
https://github.com/TheHive-Project/Cortex-Analyzers/blob/8dae6a8c4cf9af5554ae8c844985c4b44d4bd4bf/analyzers/TorProject/tor_project.py#L52-L80
230,901
TheHive-Project/Cortex-Analyzers
analyzers/Censys/censys_analyzer.py
CensysAnalyzer.search_hosts
def search_hosts(self, ip): """ Searches for a host using its ipv4 address :param ip: ipv4 address as string :type ip: str :return: dict """ c = CensysIPv4(api_id=self.__uid, api_secret=self.__api_key) return c.view(ip)
python
def search_hosts(self, ip): """ Searches for a host using its ipv4 address :param ip: ipv4 address as string :type ip: str :return: dict """ c = CensysIPv4(api_id=self.__uid, api_secret=self.__api_key) return c.view(ip)
[ "def", "search_hosts", "(", "self", ",", "ip", ")", ":", "c", "=", "CensysIPv4", "(", "api_id", "=", "self", ".", "__uid", ",", "api_secret", "=", "self", ".", "__api_key", ")", "return", "c", ".", "view", "(", "ip", ")" ]
Searches for a host using its ipv4 address :param ip: ipv4 address as string :type ip: str :return: dict
[ "Searches", "for", "a", "host", "using", "its", "ipv4", "address" ]
8dae6a8c4cf9af5554ae8c844985c4b44d4bd4bf
https://github.com/TheHive-Project/Cortex-Analyzers/blob/8dae6a8c4cf9af5554ae8c844985c4b44d4bd4bf/analyzers/Censys/censys_analyzer.py#L24-L33
230,902
TheHive-Project/Cortex-Analyzers
analyzers/Censys/censys_analyzer.py
CensysAnalyzer.search_certificate
def search_certificate(self, hash): """ Searches for a specific certificate using its hash :param hash: certificate hash :type hash: str :return: dict """ c = CensysCertificates(api_id=self.__uid, api_secret=self.__api_key) return c.view(hash)
python
def search_certificate(self, hash): """ Searches for a specific certificate using its hash :param hash: certificate hash :type hash: str :return: dict """ c = CensysCertificates(api_id=self.__uid, api_secret=self.__api_key) return c.view(hash)
[ "def", "search_certificate", "(", "self", ",", "hash", ")", ":", "c", "=", "CensysCertificates", "(", "api_id", "=", "self", ".", "__uid", ",", "api_secret", "=", "self", ".", "__api_key", ")", "return", "c", ".", "view", "(", "hash", ")" ]
Searches for a specific certificate using its hash :param hash: certificate hash :type hash: str :return: dict
[ "Searches", "for", "a", "specific", "certificate", "using", "its", "hash" ]
8dae6a8c4cf9af5554ae8c844985c4b44d4bd4bf
https://github.com/TheHive-Project/Cortex-Analyzers/blob/8dae6a8c4cf9af5554ae8c844985c4b44d4bd4bf/analyzers/Censys/censys_analyzer.py#L35-L44
230,903
TheHive-Project/Cortex-Analyzers
analyzers/StopForumSpam/stopforumspam_client.py
StopforumspamClient.get_data
def get_data(self, datatype, data): """ Look for an IP address or an email address in the spammer database. :param datatype: Which type of data is to be looked up. Allowed values are 'ip' or 'mail'. :param data: The value to be looked up through the API. :type d...
python
def get_data(self, datatype, data): """ Look for an IP address or an email address in the spammer database. :param datatype: Which type of data is to be looked up. Allowed values are 'ip' or 'mail'. :param data: The value to be looked up through the API. :type d...
[ "def", "get_data", "(", "self", ",", "datatype", ",", "data", ")", ":", "result", "=", "{", "}", "params", "=", "StopforumspamClient", ".", "_set_payload", "(", "datatype", ",", "data", ")", "response", "=", "self", ".", "client", ".", "get", "(", "'ht...
Look for an IP address or an email address in the spammer database. :param datatype: Which type of data is to be looked up. Allowed values are 'ip' or 'mail'. :param data: The value to be looked up through the API. :type datatype: str :type data: str :re...
[ "Look", "for", "an", "IP", "address", "or", "an", "email", "address", "in", "the", "spammer", "database", "." ]
8dae6a8c4cf9af5554ae8c844985c4b44d4bd4bf
https://github.com/TheHive-Project/Cortex-Analyzers/blob/8dae6a8c4cf9af5554ae8c844985c4b44d4bd4bf/analyzers/StopForumSpam/stopforumspam_client.py#L47-L70
230,904
sdispater/orator
orator/orm/factory.py
Factory.construct
def construct(cls, faker, path_to_factories=None): """ Create a new factory container. :param faker: A faker generator instance :type faker: faker.Generator :param path_to_factories: The path to factories :type path_to_factories: str :rtype: Factory """...
python
def construct(cls, faker, path_to_factories=None): """ Create a new factory container. :param faker: A faker generator instance :type faker: faker.Generator :param path_to_factories: The path to factories :type path_to_factories: str :rtype: Factory """...
[ "def", "construct", "(", "cls", ",", "faker", ",", "path_to_factories", "=", "None", ")", ":", "factory", "=", "faker", ".", "__class__", "(", ")", "if", "path_to_factories", "is", "not", "None", "and", "os", ".", "path", ".", "isdir", "(", "path_to_fact...
Create a new factory container. :param faker: A faker generator instance :type faker: faker.Generator :param path_to_factories: The path to factories :type path_to_factories: str :rtype: Factory
[ "Create", "a", "new", "factory", "container", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/factory.py#L25-L44
230,905
sdispater/orator
orator/orm/factory.py
Factory.define
def define(self, klass, name="default"): """ Define a class with a given set of attributes. :param klass: The class :type klass: class :param name: The short name :type name: str """ def decorate(func): @wraps(func) def wrapped(*...
python
def define(self, klass, name="default"): """ Define a class with a given set of attributes. :param klass: The class :type klass: class :param name: The short name :type name: str """ def decorate(func): @wraps(func) def wrapped(*...
[ "def", "define", "(", "self", ",", "klass", ",", "name", "=", "\"default\"", ")", ":", "def", "decorate", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "fun...
Define a class with a given set of attributes. :param klass: The class :type klass: class :param name: The short name :type name: str
[ "Define", "a", "class", "with", "a", "given", "set", "of", "attributes", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/factory.py#L58-L78
230,906
sdispater/orator
orator/orm/factory.py
Factory.create_as
def create_as(self, klass, name, **attributes): """ Create an instance of the given model and type and persist it to the database. :param klass: The class :type klass: class :param name: The type :type name: str :param attributes: The instance attributes ...
python
def create_as(self, klass, name, **attributes): """ Create an instance of the given model and type and persist it to the database. :param klass: The class :type klass: class :param name: The type :type name: str :param attributes: The instance attributes ...
[ "def", "create_as", "(", "self", ",", "klass", ",", "name", ",", "*", "*", "attributes", ")", ":", "return", "self", ".", "of", "(", "klass", ",", "name", ")", ".", "create", "(", "*", "*", "attributes", ")" ]
Create an instance of the given model and type and persist it to the database. :param klass: The class :type klass: class :param name: The type :type name: str :param attributes: The instance attributes :type attributes: dict :return: mixed
[ "Create", "an", "instance", "of", "the", "given", "model", "and", "type", "and", "persist", "it", "to", "the", "database", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/factory.py#L127-L142
230,907
sdispater/orator
orator/orm/factory.py
Factory.make_as
def make_as(self, klass, name, **attributes): """ Create an instance of the given model and type. :param klass: The class :type klass: class :param name: The type :type name: str :param attributes: The instance attributes :type attributes: dict ...
python
def make_as(self, klass, name, **attributes): """ Create an instance of the given model and type. :param klass: The class :type klass: class :param name: The type :type name: str :param attributes: The instance attributes :type attributes: dict ...
[ "def", "make_as", "(", "self", ",", "klass", ",", "name", ",", "*", "*", "attributes", ")", ":", "return", "self", ".", "of", "(", "klass", ",", "name", ")", ".", "make", "(", "*", "*", "attributes", ")" ]
Create an instance of the given model and type. :param klass: The class :type klass: class :param name: The type :type name: str :param attributes: The instance attributes :type attributes: dict :return: mixed
[ "Create", "an", "instance", "of", "the", "given", "model", "and", "type", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/factory.py#L158-L173
230,908
sdispater/orator
orator/orm/factory.py
Factory.of
def of(self, klass, name="default"): """ Create a builder for the given model. :param klass: The class :type klass: class :param name: The type :type name: str :return: orator.orm.factory_builder.FactoryBuilder """ return FactoryBuilder( ...
python
def of(self, klass, name="default"): """ Create a builder for the given model. :param klass: The class :type klass: class :param name: The type :type name: str :return: orator.orm.factory_builder.FactoryBuilder """ return FactoryBuilder( ...
[ "def", "of", "(", "self", ",", "klass", ",", "name", "=", "\"default\"", ")", ":", "return", "FactoryBuilder", "(", "klass", ",", "name", ",", "self", ".", "_definitions", ",", "self", ".", "_faker", ",", "self", ".", "_resolver", ")" ]
Create a builder for the given model. :param klass: The class :type klass: class :param name: The type :type name: str :return: orator.orm.factory_builder.FactoryBuilder
[ "Create", "a", "builder", "for", "the", "given", "model", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/factory.py#L213-L227
230,909
sdispater/orator
orator/orm/factory.py
Factory.build
def build(self, klass, name="default", amount=None): """ Makes a factory builder with a specified amount. :param klass: The class :type klass: class :param name: The type :type name: str :param amount: The number of models to create :type amount: int ...
python
def build(self, klass, name="default", amount=None): """ Makes a factory builder with a specified amount. :param klass: The class :type klass: class :param name: The type :type name: str :param amount: The number of models to create :type amount: int ...
[ "def", "build", "(", "self", ",", "klass", ",", "name", "=", "\"default\"", ",", "amount", "=", "None", ")", ":", "if", "amount", "is", "None", ":", "if", "isinstance", "(", "name", ",", "int", ")", ":", "amount", "=", "name", "name", "=", "\"defau...
Makes a factory builder with a specified amount. :param klass: The class :type klass: class :param name: The type :type name: str :param amount: The number of models to create :type amount: int :return: mixed
[ "Makes", "a", "factory", "builder", "with", "a", "specified", "amount", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/factory.py#L229-L251
230,910
sdispater/orator
orator/schema/grammars/grammar.py
SchemaGrammar._get_renamed_diff
def _get_renamed_diff(self, blueprint, command, column, schema): """ Get a new column instance with the new column name. :param blueprint: The blueprint :type blueprint: Blueprint :param command: The command :type command: Fluent :param column: The column ...
python
def _get_renamed_diff(self, blueprint, command, column, schema): """ Get a new column instance with the new column name. :param blueprint: The blueprint :type blueprint: Blueprint :param command: The command :type command: Fluent :param column: The column ...
[ "def", "_get_renamed_diff", "(", "self", ",", "blueprint", ",", "command", ",", "column", ",", "schema", ")", ":", "table_diff", "=", "self", ".", "_get_table_diff", "(", "blueprint", ",", "schema", ")", "return", "self", ".", "_set_renamed_columns", "(", "t...
Get a new column instance with the new column name. :param blueprint: The blueprint :type blueprint: Blueprint :param command: The command :type command: Fluent :param column: The column :type column: orator.dbal.Column :param schema: The schema :type ...
[ "Get", "a", "new", "column", "instance", "with", "the", "new", "column", "name", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/grammars/grammar.py#L43-L63
230,911
sdispater/orator
orator/schema/grammars/grammar.py
SchemaGrammar._set_renamed_columns
def _set_renamed_columns(self, table_diff, command, column): """ Set the renamed columns on the table diff. :rtype: orator.dbal.TableDiff """ new_column = Column(command.to, column.get_type(), column.to_dict()) table_diff.renamed_columns = {command.from_: new_column} ...
python
def _set_renamed_columns(self, table_diff, command, column): """ Set the renamed columns on the table diff. :rtype: orator.dbal.TableDiff """ new_column = Column(command.to, column.get_type(), column.to_dict()) table_diff.renamed_columns = {command.from_: new_column} ...
[ "def", "_set_renamed_columns", "(", "self", ",", "table_diff", ",", "command", ",", "column", ")", ":", "new_column", "=", "Column", "(", "command", ".", "to", ",", "column", ".", "get_type", "(", ")", ",", "column", ".", "to_dict", "(", ")", ")", "tab...
Set the renamed columns on the table diff. :rtype: orator.dbal.TableDiff
[ "Set", "the", "renamed", "columns", "on", "the", "table", "diff", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/grammars/grammar.py#L65-L75
230,912
sdispater/orator
orator/schema/grammars/grammar.py
SchemaGrammar._get_command_by_name
def _get_command_by_name(self, blueprint, name): """ Get the primary key command it it exists. """ commands = self._get_commands_by_name(blueprint, name) if len(commands): return commands[0]
python
def _get_command_by_name(self, blueprint, name): """ Get the primary key command it it exists. """ commands = self._get_commands_by_name(blueprint, name) if len(commands): return commands[0]
[ "def", "_get_command_by_name", "(", "self", ",", "blueprint", ",", "name", ")", ":", "commands", "=", "self", ".", "_get_commands_by_name", "(", "blueprint", ",", "name", ")", "if", "len", "(", "commands", ")", ":", "return", "commands", "[", "0", "]" ]
Get the primary key command it it exists.
[ "Get", "the", "primary", "key", "command", "it", "it", "exists", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/grammars/grammar.py#L143-L150
230,913
sdispater/orator
orator/schema/grammars/grammar.py
SchemaGrammar._get_commands_by_name
def _get_commands_by_name(self, blueprint, name): """ Get all of the commands with a given name. """ return list(filter(lambda value: value.name == name, blueprint.get_commands()))
python
def _get_commands_by_name(self, blueprint, name): """ Get all of the commands with a given name. """ return list(filter(lambda value: value.name == name, blueprint.get_commands()))
[ "def", "_get_commands_by_name", "(", "self", ",", "blueprint", ",", "name", ")", ":", "return", "list", "(", "filter", "(", "lambda", "value", ":", "value", ".", "name", "==", "name", ",", "blueprint", ".", "get_commands", "(", ")", ")", ")" ]
Get all of the commands with a given name.
[ "Get", "all", "of", "the", "commands", "with", "a", "given", "name", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/grammars/grammar.py#L152-L156
230,914
sdispater/orator
orator/schema/grammars/grammar.py
SchemaGrammar.prefix_list
def prefix_list(self, prefix, values): """ Add a prefix to a list of values. """ return list(map(lambda value: prefix + " " + value, values))
python
def prefix_list(self, prefix, values): """ Add a prefix to a list of values. """ return list(map(lambda value: prefix + " " + value, values))
[ "def", "prefix_list", "(", "self", ",", "prefix", ",", "values", ")", ":", "return", "list", "(", "map", "(", "lambda", "value", ":", "prefix", "+", "\" \"", "+", "value", ",", "values", ")", ")" ]
Add a prefix to a list of values.
[ "Add", "a", "prefix", "to", "a", "list", "of", "values", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/grammars/grammar.py#L169-L173
230,915
sdispater/orator
orator/schema/grammars/grammar.py
SchemaGrammar._get_default_value
def _get_default_value(self, value): """ Format a value so that it can be used in "default" clauses. """ if isinstance(value, QueryExpression): return value if isinstance(value, bool): return "'%s'" % int(value) return "'%s'" % value
python
def _get_default_value(self, value): """ Format a value so that it can be used in "default" clauses. """ if isinstance(value, QueryExpression): return value if isinstance(value, bool): return "'%s'" % int(value) return "'%s'" % value
[ "def", "_get_default_value", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "QueryExpression", ")", ":", "return", "value", "if", "isinstance", "(", "value", ",", "bool", ")", ":", "return", "\"'%s'\"", "%", "int", "(", "valu...
Format a value so that it can be used in "default" clauses.
[ "Format", "a", "value", "so", "that", "it", "can", "be", "used", "in", "default", "clauses", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/grammars/grammar.py#L187-L197
230,916
sdispater/orator
orator/schema/grammars/grammar.py
SchemaGrammar._get_changed_diff
def _get_changed_diff(self, blueprint, schema): """ Get the table diffrence for the given changes. :param blueprint: The blueprint :type blueprint: Blueprint :param schema: The schema :type schema: orator.dbal.SchemaManager :rtype: orator.dbal.TableDiff ...
python
def _get_changed_diff(self, blueprint, schema): """ Get the table diffrence for the given changes. :param blueprint: The blueprint :type blueprint: Blueprint :param schema: The schema :type schema: orator.dbal.SchemaManager :rtype: orator.dbal.TableDiff ...
[ "def", "_get_changed_diff", "(", "self", ",", "blueprint", ",", "schema", ")", ":", "table", "=", "schema", ".", "list_table_details", "(", "self", ".", "get_table_prefix", "(", ")", "+", "blueprint", ".", "get_table", "(", ")", ")", "return", "Comparator", ...
Get the table diffrence for the given changes. :param blueprint: The blueprint :type blueprint: Blueprint :param schema: The schema :type schema: orator.dbal.SchemaManager :rtype: orator.dbal.TableDiff
[ "Get", "the", "table", "diffrence", "for", "the", "given", "changes", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/grammars/grammar.py#L237-L255
230,917
sdispater/orator
orator/schema/grammars/grammar.py
SchemaGrammar._get_table_with_column_changes
def _get_table_with_column_changes(self, blueprint, table): """ Get a copy of the given table after making the column changes. :param blueprint: The blueprint :type blueprint: Blueprint :type table: orator.dbal.table.Table :rtype: orator.dbal.table.Table """ ...
python
def _get_table_with_column_changes(self, blueprint, table): """ Get a copy of the given table after making the column changes. :param blueprint: The blueprint :type blueprint: Blueprint :type table: orator.dbal.table.Table :rtype: orator.dbal.table.Table """ ...
[ "def", "_get_table_with_column_changes", "(", "self", ",", "blueprint", ",", "table", ")", ":", "table", "=", "table", ".", "clone", "(", ")", "for", "fluent", "in", "blueprint", ".", "get_changed_columns", "(", ")", ":", "column", "=", "self", ".", "_get_...
Get a copy of the given table after making the column changes. :param blueprint: The blueprint :type blueprint: Blueprint :type table: orator.dbal.table.Table :rtype: orator.dbal.table.Table
[ "Get", "a", "copy", "of", "the", "given", "table", "after", "making", "the", "column", "changes", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/grammars/grammar.py#L257-L282
230,918
sdispater/orator
orator/schema/grammars/grammar.py
SchemaGrammar._get_column_for_change
def _get_column_for_change(self, table, fluent): """ Get the column instance for a column change. :type table: orator.dbal.table.Table :rtype: orator.dbal.column.Column """ return table.change_column( fluent.name, self._get_column_change_options(fluent) ...
python
def _get_column_for_change(self, table, fluent): """ Get the column instance for a column change. :type table: orator.dbal.table.Table :rtype: orator.dbal.column.Column """ return table.change_column( fluent.name, self._get_column_change_options(fluent) ...
[ "def", "_get_column_for_change", "(", "self", ",", "table", ",", "fluent", ")", ":", "return", "table", ".", "change_column", "(", "fluent", ".", "name", ",", "self", ".", "_get_column_change_options", "(", "fluent", ")", ")", ".", "get_column", "(", "fluent...
Get the column instance for a column change. :type table: orator.dbal.table.Table :rtype: orator.dbal.column.Column
[ "Get", "the", "column", "instance", "for", "a", "column", "change", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/grammars/grammar.py#L284-L294
230,919
sdispater/orator
orator/orm/relations/pivot.py
Pivot._get_delete_query
def _get_delete_query(self): """ Get the query builder for a delete operation on the pivot. :rtype: orator.orm.Builder """ foreign = self.get_attribute(self.__foreign_key) query = self.new_query().where(self.__foreign_key, foreign) return query.where(self.__oth...
python
def _get_delete_query(self): """ Get the query builder for a delete operation on the pivot. :rtype: orator.orm.Builder """ foreign = self.get_attribute(self.__foreign_key) query = self.new_query().where(self.__foreign_key, foreign) return query.where(self.__oth...
[ "def", "_get_delete_query", "(", "self", ")", ":", "foreign", "=", "self", ".", "get_attribute", "(", "self", ".", "__foreign_key", ")", "query", "=", "self", ".", "new_query", "(", ")", ".", "where", "(", "self", ".", "__foreign_key", ",", "foreign", ")...
Get the query builder for a delete operation on the pivot. :rtype: orator.orm.Builder
[ "Get", "the", "query", "builder", "for", "a", "delete", "operation", "on", "the", "pivot", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/pivot.py#L63-L73
230,920
sdispater/orator
orator/orm/relations/pivot.py
Pivot.set_pivot_keys
def set_pivot_keys(self, foreign_key, other_key): """ Set the key names for the pivot model instance """ self.__foreign_key = foreign_key self.__other_key = other_key return self
python
def set_pivot_keys(self, foreign_key, other_key): """ Set the key names for the pivot model instance """ self.__foreign_key = foreign_key self.__other_key = other_key return self
[ "def", "set_pivot_keys", "(", "self", ",", "foreign_key", ",", "other_key", ")", ":", "self", ".", "__foreign_key", "=", "foreign_key", "self", ".", "__other_key", "=", "other_key", "return", "self" ]
Set the key names for the pivot model instance
[ "Set", "the", "key", "names", "for", "the", "pivot", "model", "instance" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/pivot.py#L89-L96
230,921
sdispater/orator
orator/orm/factory_builder.py
FactoryBuilder.create
def create(self, **attributes): """ Create a collection of models and persist them to the database. :param attributes: The models attributes :type attributes: dict :return: mixed """ results = self.make(**attributes) if self._amount == 1: if...
python
def create(self, **attributes): """ Create a collection of models and persist them to the database. :param attributes: The models attributes :type attributes: dict :return: mixed """ results = self.make(**attributes) if self._amount == 1: if...
[ "def", "create", "(", "self", ",", "*", "*", "attributes", ")", ":", "results", "=", "self", ".", "make", "(", "*", "*", "attributes", ")", "if", "self", ".", "_amount", "==", "1", ":", "if", "self", ".", "_resolver", ":", "results", ".", "set_conn...
Create a collection of models and persist them to the database. :param attributes: The models attributes :type attributes: dict :return: mixed
[ "Create", "a", "collection", "of", "models", "and", "persist", "them", "to", "the", "database", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/factory_builder.py#L41-L64
230,922
sdispater/orator
orator/orm/factory_builder.py
FactoryBuilder.make
def make(self, **attributes): """ Create a collection of models. :param attributes: The models attributes :type attributes: dict :return: mixed """ if self._amount == 1: return self._make_instance(**attributes) else: results = [] ...
python
def make(self, **attributes): """ Create a collection of models. :param attributes: The models attributes :type attributes: dict :return: mixed """ if self._amount == 1: return self._make_instance(**attributes) else: results = [] ...
[ "def", "make", "(", "self", ",", "*", "*", "attributes", ")", ":", "if", "self", ".", "_amount", "==", "1", ":", "return", "self", ".", "_make_instance", "(", "*", "*", "attributes", ")", "else", ":", "results", "=", "[", "]", "for", "_", "in", "...
Create a collection of models. :param attributes: The models attributes :type attributes: dict :return: mixed
[ "Create", "a", "collection", "of", "models", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/factory_builder.py#L66-L83
230,923
sdispater/orator
orator/orm/factory_builder.py
FactoryBuilder._make_instance
def _make_instance(self, **attributes): """ Make an instance of the model with the given attributes. :param attributes: The models attributes :type attributes: dict :return: mixed """ definition = self._definitions[self._klass][self._name](self._faker) d...
python
def _make_instance(self, **attributes): """ Make an instance of the model with the given attributes. :param attributes: The models attributes :type attributes: dict :return: mixed """ definition = self._definitions[self._klass][self._name](self._faker) d...
[ "def", "_make_instance", "(", "self", ",", "*", "*", "attributes", ")", ":", "definition", "=", "self", ".", "_definitions", "[", "self", ".", "_klass", "]", "[", "self", ".", "_name", "]", "(", "self", ".", "_faker", ")", "definition", ".", "update", ...
Make an instance of the model with the given attributes. :param attributes: The models attributes :type attributes: dict :return: mixed
[ "Make", "an", "instance", "of", "the", "model", "with", "the", "given", "attributes", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/factory_builder.py#L85-L100
230,924
sdispater/orator
orator/connections/connection.py
run
def run(wrapped): """ Special decorator encapsulating query method. """ @wraps(wrapped) def _run(self, query, bindings=None, *args, **kwargs): self._reconnect_if_missing_connection() start = time.time() try: result = wrapped(self, query, bindings, *args, **kwarg...
python
def run(wrapped): """ Special decorator encapsulating query method. """ @wraps(wrapped) def _run(self, query, bindings=None, *args, **kwargs): self._reconnect_if_missing_connection() start = time.time() try: result = wrapped(self, query, bindings, *args, **kwarg...
[ "def", "run", "(", "wrapped", ")", ":", "@", "wraps", "(", "wrapped", ")", "def", "_run", "(", "self", ",", "query", ",", "bindings", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_reconnect_if_missing_connection", "...
Special decorator encapsulating query method.
[ "Special", "decorator", "encapsulating", "query", "method", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/connections/connection.py#L21-L43
230,925
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany.where_pivot
def where_pivot(self, column, operator=None, value=None, boolean="and"): """ Set a where clause for a pivot table column. :param column: The column of the where clause, can also be a QueryBuilder instance for sub where :type column: str|Builder :param operator: The operator of ...
python
def where_pivot(self, column, operator=None, value=None, boolean="and"): """ Set a where clause for a pivot table column. :param column: The column of the where clause, can also be a QueryBuilder instance for sub where :type column: str|Builder :param operator: The operator of ...
[ "def", "where_pivot", "(", "self", ",", "column", ",", "operator", "=", "None", ",", "value", "=", "None", ",", "boolean", "=", "\"and\"", ")", ":", "self", ".", "_pivot_wheres", ".", "append", "(", "[", "column", ",", "operator", ",", "value", ",", ...
Set a where clause for a pivot table column. :param column: The column of the where clause, can also be a QueryBuilder instance for sub where :type column: str|Builder :param operator: The operator of the where clause :type operator: str :param value: The value of the where cl...
[ "Set", "a", "where", "clause", "for", "a", "pivot", "table", "column", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L62-L85
230,926
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany.or_where_pivot
def or_where_pivot(self, column, operator=None, value=None): """ Set an or where clause for a pivot table column. :param column: The column of the where clause, can also be a QueryBuilder instance for sub where :type column: str|Builder :param operator: The operator of the wher...
python
def or_where_pivot(self, column, operator=None, value=None): """ Set an or where clause for a pivot table column. :param column: The column of the where clause, can also be a QueryBuilder instance for sub where :type column: str|Builder :param operator: The operator of the wher...
[ "def", "or_where_pivot", "(", "self", ",", "column", ",", "operator", "=", "None", ",", "value", "=", "None", ")", ":", "return", "self", ".", "where_pivot", "(", "column", ",", "operator", ",", "value", ",", "\"or\"", ")" ]
Set an or where clause for a pivot table column. :param column: The column of the where clause, can also be a QueryBuilder instance for sub where :type column: str|Builder :param operator: The operator of the where clause :type operator: str :param value: The value of the wher...
[ "Set", "an", "or", "where", "clause", "for", "a", "pivot", "table", "column", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L87-L103
230,927
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany.first
def first(self, columns=None): """ Execute the query and get the first result. :type columns: list """ self._query.take(1) results = self.get(columns) if len(results) > 0: return results.first() return
python
def first(self, columns=None): """ Execute the query and get the first result. :type columns: list """ self._query.take(1) results = self.get(columns) if len(results) > 0: return results.first() return
[ "def", "first", "(", "self", ",", "columns", "=", "None", ")", ":", "self", ".", "_query", ".", "take", "(", "1", ")", "results", "=", "self", ".", "get", "(", "columns", ")", "if", "len", "(", "results", ")", ">", "0", ":", "return", "results", ...
Execute the query and get the first result. :type columns: list
[ "Execute", "the", "query", "and", "get", "the", "first", "result", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L105-L118
230,928
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany.first_or_fail
def first_or_fail(self, columns=None): """ Execute the query and get the first result or raise an exception. :type columns: list :raises: ModelNotFound """ model = self.first(columns) if model is not None: return model raise ModelNotFound(se...
python
def first_or_fail(self, columns=None): """ Execute the query and get the first result or raise an exception. :type columns: list :raises: ModelNotFound """ model = self.first(columns) if model is not None: return model raise ModelNotFound(se...
[ "def", "first_or_fail", "(", "self", ",", "columns", "=", "None", ")", ":", "model", "=", "self", ".", "first", "(", "columns", ")", "if", "model", "is", "not", "None", ":", "return", "model", "raise", "ModelNotFound", "(", "self", ".", "_parent", ".",...
Execute the query and get the first result or raise an exception. :type columns: list :raises: ModelNotFound
[ "Execute", "the", "query", "and", "get", "the", "first", "result", "or", "raise", "an", "exception", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L120-L132
230,929
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany._hydrate_pivot_relation
def _hydrate_pivot_relation(self, models): """ Hydrate the pivot table relationship on the models. :type models: list """ for model in models: pivot = self.new_existing_pivot(self._clean_pivot_attributes(model)) model.set_relation("pivot", pivot)
python
def _hydrate_pivot_relation(self, models): """ Hydrate the pivot table relationship on the models. :type models: list """ for model in models: pivot = self.new_existing_pivot(self._clean_pivot_attributes(model)) model.set_relation("pivot", pivot)
[ "def", "_hydrate_pivot_relation", "(", "self", ",", "models", ")", ":", "for", "model", "in", "models", ":", "pivot", "=", "self", ".", "new_existing_pivot", "(", "self", ".", "_clean_pivot_attributes", "(", "model", ")", ")", "model", ".", "set_relation", "...
Hydrate the pivot table relationship on the models. :type models: list
[ "Hydrate", "the", "pivot", "table", "relationship", "on", "the", "models", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L159-L168
230,930
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany.touch
def touch(self): """ Touch all of the related models of the relationship. """ key = self.get_related().get_key_name() columns = self.get_related_fresh_update() ids = self.get_related_ids() if len(ids) > 0: self.get_related().new_query().where_in(key...
python
def touch(self): """ Touch all of the related models of the relationship. """ key = self.get_related().get_key_name() columns = self.get_related_fresh_update() ids = self.get_related_ids() if len(ids) > 0: self.get_related().new_query().where_in(key...
[ "def", "touch", "(", "self", ")", ":", "key", "=", "self", ".", "get_related", "(", ")", ".", "get_key_name", "(", ")", "columns", "=", "self", ".", "get_related_fresh_update", "(", ")", "ids", "=", "self", ".", "get_related_ids", "(", ")", "if", "len"...
Touch all of the related models of the relationship.
[ "Touch", "all", "of", "the", "related", "models", "of", "the", "relationship", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L391-L402
230,931
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany.get_related_ids
def get_related_ids(self): """ Get all of the IDs for the related models. :rtype: list """ related = self.get_related() full_key = related.get_qualified_key_name() return self.get_query().select(full_key).lists(related.get_key_name())
python
def get_related_ids(self): """ Get all of the IDs for the related models. :rtype: list """ related = self.get_related() full_key = related.get_qualified_key_name() return self.get_query().select(full_key).lists(related.get_key_name())
[ "def", "get_related_ids", "(", "self", ")", ":", "related", "=", "self", ".", "get_related", "(", ")", "full_key", "=", "related", ".", "get_qualified_key_name", "(", ")", "return", "self", ".", "get_query", "(", ")", ".", "select", "(", "full_key", ")", ...
Get all of the IDs for the related models. :rtype: list
[ "Get", "all", "of", "the", "IDs", "for", "the", "related", "models", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L404-L414
230,932
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany.save_many
def save_many(self, models, joinings=None): """ Save a list of new models and attach them to the parent model :type models: list :type joinings: dict :rtype: list """ if joinings is None: joinings = {} for key, model in enumerate(models): ...
python
def save_many(self, models, joinings=None): """ Save a list of new models and attach them to the parent model :type models: list :type joinings: dict :rtype: list """ if joinings is None: joinings = {} for key, model in enumerate(models): ...
[ "def", "save_many", "(", "self", ",", "models", ",", "joinings", "=", "None", ")", ":", "if", "joinings", "is", "None", ":", "joinings", "=", "{", "}", "for", "key", ",", "model", "in", "enumerate", "(", "models", ")", ":", "self", ".", "save", "("...
Save a list of new models and attach them to the parent model :type models: list :type joinings: dict :rtype: list
[ "Save", "a", "list", "of", "new", "models", "and", "attach", "them", "to", "the", "parent", "model" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L435-L452
230,933
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany.first_or_create
def first_or_create( self, _attributes=None, _joining=None, _touch=True, **attributes ): """ Get the first related model record matching the attributes or create it. :param attributes: The attributes :type attributes: dict :rtype: Model """ if _attr...
python
def first_or_create( self, _attributes=None, _joining=None, _touch=True, **attributes ): """ Get the first related model record matching the attributes or create it. :param attributes: The attributes :type attributes: dict :rtype: Model """ if _attr...
[ "def", "first_or_create", "(", "self", ",", "_attributes", "=", "None", ",", "_joining", "=", "None", ",", "_touch", "=", "True", ",", "*", "*", "attributes", ")", ":", "if", "_attributes", "is", "not", "None", ":", "attributes", ".", "update", "(", "_...
Get the first related model record matching the attributes or create it. :param attributes: The attributes :type attributes: dict :rtype: Model
[ "Get", "the", "first", "related", "model", "record", "matching", "the", "attributes", "or", "create", "it", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L490-L508
230,934
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany.sync
def sync(self, ids, detaching=True): """ Sync the intermediate tables with a list of IDs or collection of models """ changes = {"attached": [], "detached": [], "updated": []} if isinstance(ids, Collection): ids = ids.model_keys() current = self._new_pivot_qu...
python
def sync(self, ids, detaching=True): """ Sync the intermediate tables with a list of IDs or collection of models """ changes = {"attached": [], "detached": [], "updated": []} if isinstance(ids, Collection): ids = ids.model_keys() current = self._new_pivot_qu...
[ "def", "sync", "(", "self", ",", "ids", ",", "detaching", "=", "True", ")", ":", "changes", "=", "{", "\"attached\"", ":", "[", "]", ",", "\"detached\"", ":", "[", "]", ",", "\"updated\"", ":", "[", "]", "}", "if", "isinstance", "(", "ids", ",", ...
Sync the intermediate tables with a list of IDs or collection of models
[ "Sync", "the", "intermediate", "tables", "with", "a", "list", "of", "IDs", "or", "collection", "of", "models" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L572-L597
230,935
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany._format_sync_list
def _format_sync_list(self, records): """ Format the sync list so that it is keyed by ID. """ results = {} for attributes in records: if not isinstance(attributes, dict): id, attributes = attributes, {} else: id = list(attr...
python
def _format_sync_list(self, records): """ Format the sync list so that it is keyed by ID. """ results = {} for attributes in records: if not isinstance(attributes, dict): id, attributes = attributes, {} else: id = list(attr...
[ "def", "_format_sync_list", "(", "self", ",", "records", ")", ":", "results", "=", "{", "}", "for", "attributes", "in", "records", ":", "if", "not", "isinstance", "(", "attributes", ",", "dict", ")", ":", "id", ",", "attributes", "=", "attributes", ",", ...
Format the sync list so that it is keyed by ID.
[ "Format", "the", "sync", "list", "so", "that", "it", "is", "keyed", "by", "ID", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L599-L614
230,936
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany.attach
def attach(self, id, attributes=None, touch=True): """ Attach a model to the parent. """ if isinstance(id, orator.orm.Model): id = id.get_key() query = self.new_pivot_statement() if not isinstance(id, list): id = [id] query.insert(self._...
python
def attach(self, id, attributes=None, touch=True): """ Attach a model to the parent. """ if isinstance(id, orator.orm.Model): id = id.get_key() query = self.new_pivot_statement() if not isinstance(id, list): id = [id] query.insert(self._...
[ "def", "attach", "(", "self", ",", "id", ",", "attributes", "=", "None", ",", "touch", "=", "True", ")", ":", "if", "isinstance", "(", "id", ",", "orator", ".", "orm", ".", "Model", ")", ":", "id", "=", "id", ".", "get_key", "(", ")", "query", ...
Attach a model to the parent.
[ "Attach", "a", "model", "to", "the", "parent", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L648-L663
230,937
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany._create_attach_records
def _create_attach_records(self, ids, attributes): """ Create a list of records to insert into the pivot table. """ records = [] timed = self._has_pivot_column(self.created_at()) or self._has_pivot_column( self.updated_at() ) for key, value in enumer...
python
def _create_attach_records(self, ids, attributes): """ Create a list of records to insert into the pivot table. """ records = [] timed = self._has_pivot_column(self.created_at()) or self._has_pivot_column( self.updated_at() ) for key, value in enumer...
[ "def", "_create_attach_records", "(", "self", ",", "ids", ",", "attributes", ")", ":", "records", "=", "[", "]", "timed", "=", "self", ".", "_has_pivot_column", "(", "self", ".", "created_at", "(", ")", ")", "or", "self", ".", "_has_pivot_column", "(", "...
Create a list of records to insert into the pivot table.
[ "Create", "a", "list", "of", "records", "to", "insert", "into", "the", "pivot", "table", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L665-L678
230,938
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany._attacher
def _attacher(self, key, value, attributes, timed): """ Create a full attachment record payload. """ id, extra = self._get_attach_id(key, value, attributes) record = self._create_attach_record(id, timed) if extra: record.update(extra) return record
python
def _attacher(self, key, value, attributes, timed): """ Create a full attachment record payload. """ id, extra = self._get_attach_id(key, value, attributes) record = self._create_attach_record(id, timed) if extra: record.update(extra) return record
[ "def", "_attacher", "(", "self", ",", "key", ",", "value", ",", "attributes", ",", "timed", ")", ":", "id", ",", "extra", "=", "self", ".", "_get_attach_id", "(", "key", ",", "value", ",", "attributes", ")", "record", "=", "self", ".", "_create_attach_...
Create a full attachment record payload.
[ "Create", "a", "full", "attachment", "record", "payload", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L680-L691
230,939
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany._get_attach_id
def _get_attach_id(self, key, value, attributes): """ Get the attach record ID and extra attributes. """ if isinstance(value, dict): key = list(value.keys())[0] attributes.update(value[key]) return [key, attributes] return value, attributes
python
def _get_attach_id(self, key, value, attributes): """ Get the attach record ID and extra attributes. """ if isinstance(value, dict): key = list(value.keys())[0] attributes.update(value[key]) return [key, attributes] return value, attributes
[ "def", "_get_attach_id", "(", "self", ",", "key", ",", "value", ",", "attributes", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "key", "=", "list", "(", "value", ".", "keys", "(", ")", ")", "[", "0", "]", "attributes", ".", ...
Get the attach record ID and extra attributes.
[ "Get", "the", "attach", "record", "ID", "and", "extra", "attributes", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L693-L703
230,940
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany._set_timestamps_on_attach
def _set_timestamps_on_attach(self, record, exists=False): """ Set the creation an update timestamps on an attach record. """ fresh = self._parent.fresh_timestamp() if not exists and self._has_pivot_column(self.created_at()): record[self.created_at()] = fresh ...
python
def _set_timestamps_on_attach(self, record, exists=False): """ Set the creation an update timestamps on an attach record. """ fresh = self._parent.fresh_timestamp() if not exists and self._has_pivot_column(self.created_at()): record[self.created_at()] = fresh ...
[ "def", "_set_timestamps_on_attach", "(", "self", ",", "record", ",", "exists", "=", "False", ")", ":", "fresh", "=", "self", ".", "_parent", ".", "fresh_timestamp", "(", ")", "if", "not", "exists", "and", "self", ".", "_has_pivot_column", "(", "self", ".",...
Set the creation an update timestamps on an attach record.
[ "Set", "the", "creation", "an", "update", "timestamps", "on", "an", "attach", "record", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L720-L732
230,941
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany.detach
def detach(self, ids=None, touch=True): """ Detach models from the relationship. """ if isinstance(ids, orator.orm.model.Model): ids = ids.get_key() if ids is None: ids = [] query = self._new_pivot_query() if not isinstance(ids, list): ...
python
def detach(self, ids=None, touch=True): """ Detach models from the relationship. """ if isinstance(ids, orator.orm.model.Model): ids = ids.get_key() if ids is None: ids = [] query = self._new_pivot_query() if not isinstance(ids, list): ...
[ "def", "detach", "(", "self", ",", "ids", "=", "None", ",", "touch", "=", "True", ")", ":", "if", "isinstance", "(", "ids", ",", "orator", ".", "orm", ".", "model", ".", "Model", ")", ":", "ids", "=", "ids", ".", "get_key", "(", ")", "if", "ids...
Detach models from the relationship.
[ "Detach", "models", "from", "the", "relationship", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L734-L757
230,942
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany.touch_if_touching
def touch_if_touching(self): """ Touch if the parent model is being touched. """ if self._touching_parent(): self.get_parent().touch() if self.get_parent().touches(self._relation_name): self.touch()
python
def touch_if_touching(self): """ Touch if the parent model is being touched. """ if self._touching_parent(): self.get_parent().touch() if self.get_parent().touches(self._relation_name): self.touch()
[ "def", "touch_if_touching", "(", "self", ")", ":", "if", "self", ".", "_touching_parent", "(", ")", ":", "self", ".", "get_parent", "(", ")", ".", "touch", "(", ")", "if", "self", ".", "get_parent", "(", ")", ".", "touches", "(", "self", ".", "_relat...
Touch if the parent model is being touched.
[ "Touch", "if", "the", "parent", "model", "is", "being", "touched", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L759-L767
230,943
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany.with_pivot
def with_pivot(self, *columns): """ Set the columns on the pivot table to retrieve. """ columns = list(columns) self._pivot_columns += columns return self
python
def with_pivot(self, *columns): """ Set the columns on the pivot table to retrieve. """ columns = list(columns) self._pivot_columns += columns return self
[ "def", "with_pivot", "(", "self", ",", "*", "columns", ")", ":", "columns", "=", "list", "(", "columns", ")", "self", ".", "_pivot_columns", "+=", "columns", "return", "self" ]
Set the columns on the pivot table to retrieve.
[ "Set", "the", "columns", "on", "the", "pivot", "table", "to", "retrieve", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L819-L827
230,944
sdispater/orator
orator/orm/relations/belongs_to_many.py
BelongsToMany.with_timestamps
def with_timestamps(self, created_at=None, updated_at=None): """ Specify that the pivot table has creation and update columns. """ if not created_at: created_at = self.created_at() if not updated_at: updated_at = self.updated_at() return self.wit...
python
def with_timestamps(self, created_at=None, updated_at=None): """ Specify that the pivot table has creation and update columns. """ if not created_at: created_at = self.created_at() if not updated_at: updated_at = self.updated_at() return self.wit...
[ "def", "with_timestamps", "(", "self", ",", "created_at", "=", "None", ",", "updated_at", "=", "None", ")", ":", "if", "not", "created_at", ":", "created_at", "=", "self", ".", "created_at", "(", ")", "if", "not", "updated_at", ":", "updated_at", "=", "s...
Specify that the pivot table has creation and update columns.
[ "Specify", "that", "the", "pivot", "table", "has", "creation", "and", "update", "columns", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L829-L839
230,945
sdispater/orator
orator/orm/relations/belongs_to.py
BelongsTo._get_eager_model_keys
def _get_eager_model_keys(self, models): """ Gather the keys from a list of related models. :type models: list :rtype: list """ keys = [] for model in models: value = getattr(model, self._foreign_key) if value is not None and value not ...
python
def _get_eager_model_keys(self, models): """ Gather the keys from a list of related models. :type models: list :rtype: list """ keys = [] for model in models: value = getattr(model, self._foreign_key) if value is not None and value not ...
[ "def", "_get_eager_model_keys", "(", "self", ",", "models", ")", ":", "keys", "=", "[", "]", "for", "model", "in", "models", ":", "value", "=", "getattr", "(", "model", ",", "self", ".", "_foreign_key", ")", "if", "value", "is", "not", "None", "and", ...
Gather the keys from a list of related models. :type models: list :rtype: list
[ "Gather", "the", "keys", "from", "a", "list", "of", "related", "models", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to.py#L87-L106
230,946
sdispater/orator
orator/orm/relations/belongs_to.py
BelongsTo.update
def update(self, _attributes=None, **attributes): """ Update the parent model on the relationship. :param attributes: The update attributes :type attributes: dict :rtype: mixed """ if _attributes is not None: attributes.update(_attributes) i...
python
def update(self, _attributes=None, **attributes): """ Update the parent model on the relationship. :param attributes: The update attributes :type attributes: dict :rtype: mixed """ if _attributes is not None: attributes.update(_attributes) i...
[ "def", "update", "(", "self", ",", "_attributes", "=", "None", ",", "*", "*", "attributes", ")", ":", "if", "_attributes", "is", "not", "None", ":", "attributes", ".", "update", "(", "_attributes", ")", "instance", "=", "self", ".", "get_results", "(", ...
Update the parent model on the relationship. :param attributes: The update attributes :type attributes: dict :rtype: mixed
[ "Update", "the", "parent", "model", "on", "the", "relationship", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to.py#L177-L191
230,947
sdispater/orator
orator/orm/relations/morph_to.py
MorphTo._build_dictionary
def _build_dictionary(self, models): """ Build a dictionary with the models. :param models: The models :type models: Collection """ for model in models: key = getattr(model, self._morph_type, None) if key: foreign = getattr(model, ...
python
def _build_dictionary(self, models): """ Build a dictionary with the models. :param models: The models :type models: Collection """ for model in models: key = getattr(model, self._morph_type, None) if key: foreign = getattr(model, ...
[ "def", "_build_dictionary", "(", "self", ",", "models", ")", ":", "for", "model", "in", "models", ":", "key", "=", "getattr", "(", "model", ",", "self", ".", "_morph_type", ",", "None", ")", "if", "key", ":", "foreign", "=", "getattr", "(", "model", ...
Build a dictionary with the models. :param models: The models :type models: Collection
[ "Build", "a", "dictionary", "with", "the", "models", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/morph_to.py#L49-L66
230,948
sdispater/orator
orator/orm/relations/morph_to.py
MorphTo.get_eager
def get_eager(self): """ Get the relationship for eager loading. :rtype: Collection """ for type in self._dictionary.keys(): self._match_to_morph_parents(type, self._get_results_by_type(type)) return self._models
python
def get_eager(self): """ Get the relationship for eager loading. :rtype: Collection """ for type in self._dictionary.keys(): self._match_to_morph_parents(type, self._get_results_by_type(type)) return self._models
[ "def", "get_eager", "(", "self", ")", ":", "for", "type", "in", "self", ".", "_dictionary", ".", "keys", "(", ")", ":", "self", ".", "_match_to_morph_parents", "(", "type", ",", "self", ".", "_get_results_by_type", "(", "type", ")", ")", "return", "self"...
Get the relationship for eager loading. :rtype: Collection
[ "Get", "the", "relationship", "for", "eager", "loading", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/morph_to.py#L93-L102
230,949
sdispater/orator
orator/orm/relations/morph_to.py
MorphTo._match_to_morph_parents
def _match_to_morph_parents(self, type, results): """ Match the results for a given type to their parent. :param type: The parent type :type type: str :param results: The results to match to their parent :type results: Collection """ for result in result...
python
def _match_to_morph_parents(self, type, results): """ Match the results for a given type to their parent. :param type: The parent type :type type: str :param results: The results to match to their parent :type results: Collection """ for result in result...
[ "def", "_match_to_morph_parents", "(", "self", ",", "type", ",", "results", ")", ":", "for", "result", "in", "results", ":", "if", "result", ".", "get_key", "(", ")", "in", "self", ".", "_dictionary", ".", "get", "(", "type", ",", "[", "]", ")", ":",...
Match the results for a given type to their parent. :param type: The parent type :type type: str :param results: The results to match to their parent :type results: Collection
[ "Match", "the", "results", "for", "a", "given", "type", "to", "their", "parent", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/morph_to.py#L104-L119
230,950
sdispater/orator
orator/orm/relations/morph_to.py
MorphTo._get_results_by_type
def _get_results_by_type(self, type): """ Get all the relation results for a type. :param type: The type :type type: str :rtype: Collection """ instance = self._create_model_by_type(type) key = instance.get_key_name() query = instance.new_query...
python
def _get_results_by_type(self, type): """ Get all the relation results for a type. :param type: The type :type type: str :rtype: Collection """ instance = self._create_model_by_type(type) key = instance.get_key_name() query = instance.new_query...
[ "def", "_get_results_by_type", "(", "self", ",", "type", ")", ":", "instance", "=", "self", ".", "_create_model_by_type", "(", "type", ")", "key", "=", "instance", ".", "get_key_name", "(", ")", "query", "=", "instance", ".", "new_query", "(", ")", "query"...
Get all the relation results for a type. :param type: The type :type type: str :rtype: Collection
[ "Get", "all", "the", "relation", "results", "for", "a", "type", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/morph_to.py#L121-L138
230,951
sdispater/orator
orator/orm/relations/morph_to.py
MorphTo._gather_keys_by_type
def _gather_keys_by_type(self, type): """ Gather all of the foreign keys for a given type. :param type: The type :type type: str :rtype: BaseCollection """ foreign = self._foreign_key keys = ( BaseCollection.make(list(self._dictionary[type]....
python
def _gather_keys_by_type(self, type): """ Gather all of the foreign keys for a given type. :param type: The type :type type: str :rtype: BaseCollection """ foreign = self._foreign_key keys = ( BaseCollection.make(list(self._dictionary[type]....
[ "def", "_gather_keys_by_type", "(", "self", ",", "type", ")", ":", "foreign", "=", "self", ".", "_foreign_key", "keys", "=", "(", "BaseCollection", ".", "make", "(", "list", "(", "self", ".", "_dictionary", "[", "type", "]", ".", "values", "(", ")", ")...
Gather all of the foreign keys for a given type. :param type: The type :type type: str :rtype: BaseCollection
[ "Gather", "all", "of", "the", "foreign", "keys", "for", "a", "given", "type", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/morph_to.py#L140-L157
230,952
sdispater/orator
orator/dbal/table.py
Table.set_primary_key
def set_primary_key(self, columns, index_name=False): """ Set the primary key. :type columns: list :type index_name: str or bool :rtype: Table """ self._add_index( self._create_index(columns, index_name or "primary", True, True) ) fo...
python
def set_primary_key(self, columns, index_name=False): """ Set the primary key. :type columns: list :type index_name: str or bool :rtype: Table """ self._add_index( self._create_index(columns, index_name or "primary", True, True) ) fo...
[ "def", "set_primary_key", "(", "self", ",", "columns", ",", "index_name", "=", "False", ")", ":", "self", ".", "_add_index", "(", "self", ".", "_create_index", "(", "columns", ",", "index_name", "or", "\"primary\"", ",", "True", ",", "True", ")", ")", "f...
Set the primary key. :type columns: list :type index_name: str or bool :rtype: Table
[ "Set", "the", "primary", "key", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L55-L72
230,953
sdispater/orator
orator/dbal/table.py
Table.drop_index
def drop_index(self, name): """ Drops an index from this table. :param name: The index name :type name: str """ name = self._normalize_identifier(name) if not self.has_index(name): raise IndexDoesNotExist(name, self._name) del self._indexes[n...
python
def drop_index(self, name): """ Drops an index from this table. :param name: The index name :type name: str """ name = self._normalize_identifier(name) if not self.has_index(name): raise IndexDoesNotExist(name, self._name) del self._indexes[n...
[ "def", "drop_index", "(", "self", ",", "name", ")", ":", "name", "=", "self", ".", "_normalize_identifier", "(", "name", ")", "if", "not", "self", ".", "has_index", "(", "name", ")", ":", "raise", "IndexDoesNotExist", "(", "name", ",", "self", ".", "_n...
Drops an index from this table. :param name: The index name :type name: str
[ "Drops", "an", "index", "from", "this", "table", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L91-L102
230,954
sdispater/orator
orator/dbal/table.py
Table.rename_index
def rename_index(self, old_name, new_name=None): """ Renames an index. :param old_name: The name of the index to rename from. :type old_name: str :param new_name: The name of the index to rename to. :type new_name: str or None :rtype: Table """ ...
python
def rename_index(self, old_name, new_name=None): """ Renames an index. :param old_name: The name of the index to rename from. :type old_name: str :param new_name: The name of the index to rename to. :type new_name: str or None :rtype: Table """ ...
[ "def", "rename_index", "(", "self", ",", "old_name", ",", "new_name", "=", "None", ")", ":", "old_name", "=", "self", ".", "_normalize_identifier", "(", "old_name", ")", "normalized_new_name", "=", "self", ".", "_normalize_identifier", "(", "new_name", ")", "i...
Renames an index. :param old_name: The name of the index to rename from. :type old_name: str :param new_name: The name of the index to rename to. :type new_name: str or None :rtype: Table
[ "Renames", "an", "index", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L114-L150
230,955
sdispater/orator
orator/dbal/table.py
Table.columns_are_indexed
def columns_are_indexed(self, columns): """ Checks if an index begins in the order of the given columns. :type columns: list :rtype: bool """ for index in self._indexes.values(): if index.spans_columns(columns): return True return Fa...
python
def columns_are_indexed(self, columns): """ Checks if an index begins in the order of the given columns. :type columns: list :rtype: bool """ for index in self._indexes.values(): if index.spans_columns(columns): return True return Fa...
[ "def", "columns_are_indexed", "(", "self", ",", "columns", ")", ":", "for", "index", "in", "self", ".", "_indexes", ".", "values", "(", ")", ":", "if", "index", ".", "spans_columns", "(", "columns", ")", ":", "return", "True", "return", "False" ]
Checks if an index begins in the order of the given columns. :type columns: list :rtype: bool
[ "Checks", "if", "an", "index", "begins", "in", "the", "order", "of", "the", "given", "columns", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L152-L164
230,956
sdispater/orator
orator/dbal/table.py
Table._create_index
def _create_index( self, columns, name, is_unique, is_primary, flags=None, options=None ): """ Creates an Index instance. :param columns: The index columns :type columns: list :param name: The index name :type name: str :param is_unique: Whether the...
python
def _create_index( self, columns, name, is_unique, is_primary, flags=None, options=None ): """ Creates an Index instance. :param columns: The index columns :type columns: list :param name: The index name :type name: str :param is_unique: Whether the...
[ "def", "_create_index", "(", "self", ",", "columns", ",", "name", ",", "is_unique", ",", "is_primary", ",", "flags", "=", "None", ",", "options", "=", "None", ")", ":", "if", "re", ".", "match", "(", "\"[^a-zA-Z0-9_]+\"", ",", "self", ".", "_normalize_id...
Creates an Index instance. :param columns: The index columns :type columns: list :param name: The index name :type name: str :param is_unique: Whether the index is unique or not :type is_unique: bool :param is_primary: Whether the index is primary or not ...
[ "Creates", "an", "Index", "instance", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L166-L202
230,957
sdispater/orator
orator/dbal/table.py
Table.add_column
def add_column(self, name, type_name, options=None): """ Adds a new column. :param name: The column name :type name: str :param type_name: The column type :type type_name: str :param options: The column options :type options: dict :rtype: Colum...
python
def add_column(self, name, type_name, options=None): """ Adds a new column. :param name: The column name :type name: str :param type_name: The column type :type type_name: str :param options: The column options :type options: dict :rtype: Colum...
[ "def", "add_column", "(", "self", ",", "name", ",", "type_name", ",", "options", "=", "None", ")", ":", "column", "=", "Column", "(", "name", ",", "type_name", ",", "options", ")", "self", ".", "_add_column", "(", "column", ")", "return", "column" ]
Adds a new column. :param name: The column name :type name: str :param type_name: The column type :type type_name: str :param options: The column options :type options: dict :rtype: Column
[ "Adds", "a", "new", "column", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L204-L223
230,958
sdispater/orator
orator/dbal/table.py
Table.change_column
def change_column(self, name, options): """ Changes column details. :param name: The column to change. :type name: str :param options: The new options. :type options: str :rtype: Table """ column = self.get_column(name) column.set_option...
python
def change_column(self, name, options): """ Changes column details. :param name: The column to change. :type name: str :param options: The new options. :type options: str :rtype: Table """ column = self.get_column(name) column.set_option...
[ "def", "change_column", "(", "self", ",", "name", ",", "options", ")", ":", "column", "=", "self", ".", "get_column", "(", "name", ")", "column", ".", "set_options", "(", "options", ")", "return", "self" ]
Changes column details. :param name: The column to change. :type name: str :param options: The new options. :type options: str :rtype: Table
[ "Changes", "column", "details", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L225-L240
230,959
sdispater/orator
orator/dbal/table.py
Table.drop_column
def drop_column(self, name): """ Drops a Column from the Table :param name: The name of the column :type name: str :rtype: Table """ name = self._normalize_identifier(name) del self._columns[name] return self
python
def drop_column(self, name): """ Drops a Column from the Table :param name: The name of the column :type name: str :rtype: Table """ name = self._normalize_identifier(name) del self._columns[name] return self
[ "def", "drop_column", "(", "self", ",", "name", ")", ":", "name", "=", "self", ".", "_normalize_identifier", "(", "name", ")", "del", "self", ".", "_columns", "[", "name", "]", "return", "self" ]
Drops a Column from the Table :param name: The name of the column :type name: str :rtype: Table
[ "Drops", "a", "Column", "from", "the", "Table" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L242-L254
230,960
sdispater/orator
orator/dbal/table.py
Table.add_named_foreign_key_constraint
def add_named_foreign_key_constraint( self, name, foreign_table, local_columns, foreign_columns, options ): """ Adds a foreign key constraint with a given name. :param name: The constraint name :type name: str :param foreign_table: Table instance or table name ...
python
def add_named_foreign_key_constraint( self, name, foreign_table, local_columns, foreign_columns, options ): """ Adds a foreign key constraint with a given name. :param name: The constraint name :type name: str :param foreign_table: Table instance or table name ...
[ "def", "add_named_foreign_key_constraint", "(", "self", ",", "name", ",", "foreign_table", ",", "local_columns", ",", "foreign_columns", ",", "options", ")", ":", "if", "isinstance", "(", "foreign_table", ",", "Table", ")", ":", "for", "column", "in", "foreign_c...
Adds a foreign key constraint with a given name. :param name: The constraint name :type name: str :param foreign_table: Table instance or table name :type foreign_table: Table or str :type local_columns: list :type foreign_columns: list :type options: dict ...
[ "Adds", "a", "foreign", "key", "constraint", "with", "a", "given", "name", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L293-L328
230,961
sdispater/orator
orator/dbal/table.py
Table._add_index
def _add_index(self, index): """ Adds an index to the table. :param index: The index to add :type index: Index :rtype: Table """ index_name = index.get_name() index_name = self._normalize_identifier(index_name) replaced_implicit_indexes = [] ...
python
def _add_index(self, index): """ Adds an index to the table. :param index: The index to add :type index: Index :rtype: Table """ index_name = index.get_name() index_name = self._normalize_identifier(index_name) replaced_implicit_indexes = [] ...
[ "def", "_add_index", "(", "self", ",", "index", ")", ":", "index_name", "=", "index", ".", "get_name", "(", ")", "index_name", "=", "self", ".", "_normalize_identifier", "(", "index_name", ")", "replaced_implicit_indexes", "=", "[", "]", "for", "name", ",", ...
Adds an index to the table. :param index: The index to add :type index: Index :rtype: Table
[ "Adds", "an", "index", "to", "the", "table", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L343-L378
230,962
sdispater/orator
orator/dbal/table.py
Table.has_foreign_key
def has_foreign_key(self, name): """ Returns whether this table has a foreign key constraint with the given name. :param name: The constraint name :type name: str :rtype: bool """ name = self._normalize_identifier(name) return name in self._fk_constrain...
python
def has_foreign_key(self, name): """ Returns whether this table has a foreign key constraint with the given name. :param name: The constraint name :type name: str :rtype: bool """ name = self._normalize_identifier(name) return name in self._fk_constrain...
[ "def", "has_foreign_key", "(", "self", ",", "name", ")", ":", "name", "=", "self", ".", "_normalize_identifier", "(", "name", ")", "return", "name", "in", "self", ".", "_fk_constraints" ]
Returns whether this table has a foreign key constraint with the given name. :param name: The constraint name :type name: str :rtype: bool
[ "Returns", "whether", "this", "table", "has", "a", "foreign", "key", "constraint", "with", "the", "given", "name", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L428-L439
230,963
sdispater/orator
orator/dbal/table.py
Table.get_foreign_key
def get_foreign_key(self, name): """ Returns the foreign key constraint with the given name. :param name: The constraint name :type name: str :rtype: ForeignKeyConstraint """ name = self._normalize_identifier(name) if not self.has_foreign_key(name): ...
python
def get_foreign_key(self, name): """ Returns the foreign key constraint with the given name. :param name: The constraint name :type name: str :rtype: ForeignKeyConstraint """ name = self._normalize_identifier(name) if not self.has_foreign_key(name): ...
[ "def", "get_foreign_key", "(", "self", ",", "name", ")", ":", "name", "=", "self", ".", "_normalize_identifier", "(", "name", ")", "if", "not", "self", ".", "has_foreign_key", "(", "name", ")", ":", "raise", "ForeignKeyDoesNotExist", "(", "name", ",", "sel...
Returns the foreign key constraint with the given name. :param name: The constraint name :type name: str :rtype: ForeignKeyConstraint
[ "Returns", "the", "foreign", "key", "constraint", "with", "the", "given", "name", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L441-L455
230,964
sdispater/orator
orator/dbal/table.py
Table.remove_foreign_key
def remove_foreign_key(self, name): """ Removes the foreign key constraint with the given name. :param name: The constraint name :type name: str """ name = self._normalize_identifier(name) if not self.has_foreign_key(name): raise ForeignKeyDoesNotExi...
python
def remove_foreign_key(self, name): """ Removes the foreign key constraint with the given name. :param name: The constraint name :type name: str """ name = self._normalize_identifier(name) if not self.has_foreign_key(name): raise ForeignKeyDoesNotExi...
[ "def", "remove_foreign_key", "(", "self", ",", "name", ")", ":", "name", "=", "self", ".", "_normalize_identifier", "(", "name", ")", "if", "not", "self", ".", "has_foreign_key", "(", "name", ")", ":", "raise", "ForeignKeyDoesNotExist", "(", "name", ",", "...
Removes the foreign key constraint with the given name. :param name: The constraint name :type name: str
[ "Removes", "the", "foreign", "key", "constraint", "with", "the", "given", "name", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L457-L469
230,965
sdispater/orator
orator/dbal/table.py
Table.get_primary_key_columns
def get_primary_key_columns(self): """ Returns the primary key columns. :rtype: list """ if not self.has_primary_key(): raise DBALException('Table "%s" has no primary key.' % self.get_name()) return self.get_primary_key().get_columns()
python
def get_primary_key_columns(self): """ Returns the primary key columns. :rtype: list """ if not self.has_primary_key(): raise DBALException('Table "%s" has no primary key.' % self.get_name()) return self.get_primary_key().get_columns()
[ "def", "get_primary_key_columns", "(", "self", ")", ":", "if", "not", "self", ".", "has_primary_key", "(", ")", ":", "raise", "DBALException", "(", "'Table \"%s\" has no primary key.'", "%", "self", ".", "get_name", "(", ")", ")", "return", "self", ".", "get_p...
Returns the primary key columns. :rtype: list
[ "Returns", "the", "primary", "key", "columns", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L511-L520
230,966
sdispater/orator
orator/dbal/table.py
Table.has_index
def has_index(self, name): """ Returns whether this table has an Index with the given name. :param name: The index name :type name: str :rtype: bool """ name = self._normalize_identifier(name) return name in self._indexes
python
def has_index(self, name): """ Returns whether this table has an Index with the given name. :param name: The index name :type name: str :rtype: bool """ name = self._normalize_identifier(name) return name in self._indexes
[ "def", "has_index", "(", "self", ",", "name", ")", ":", "name", "=", "self", ".", "_normalize_identifier", "(", "name", ")", "return", "name", "in", "self", ".", "_indexes" ]
Returns whether this table has an Index with the given name. :param name: The index name :type name: str :rtype: bool
[ "Returns", "whether", "this", "table", "has", "an", "Index", "with", "the", "given", "name", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L533-L544
230,967
sdispater/orator
orator/dbal/table.py
Table.get_index
def get_index(self, name): """ Returns the Index with the given name. :param name: The index name :type name: str :rtype: Index """ name = self._normalize_identifier(name) if not self.has_index(name): raise IndexDoesNotExist(name, self._name)...
python
def get_index(self, name): """ Returns the Index with the given name. :param name: The index name :type name: str :rtype: Index """ name = self._normalize_identifier(name) if not self.has_index(name): raise IndexDoesNotExist(name, self._name)...
[ "def", "get_index", "(", "self", ",", "name", ")", ":", "name", "=", "self", ".", "_normalize_identifier", "(", "name", ")", "if", "not", "self", ".", "has_index", "(", "name", ")", ":", "raise", "IndexDoesNotExist", "(", "name", ",", "self", ".", "_na...
Returns the Index with the given name. :param name: The index name :type name: str :rtype: Index
[ "Returns", "the", "Index", "with", "the", "given", "name", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L546-L559
230,968
sdispater/orator
orator/orm/builder.py
Builder.without_global_scope
def without_global_scope(self, scope): """ Remove a registered global scope. :param scope: The scope to remove :type scope: Scope or str :rtype: Builder """ if isinstance(scope, basestring): del self._scopes[scope] return self k...
python
def without_global_scope(self, scope): """ Remove a registered global scope. :param scope: The scope to remove :type scope: Scope or str :rtype: Builder """ if isinstance(scope, basestring): del self._scopes[scope] return self k...
[ "def", "without_global_scope", "(", "self", ",", "scope", ")", ":", "if", "isinstance", "(", "scope", ",", "basestring", ")", ":", "del", "self", ".", "_scopes", "[", "scope", "]", "return", "self", "keys", "=", "[", "]", "for", "key", ",", "value", ...
Remove a registered global scope. :param scope: The scope to remove :type scope: Scope or str :rtype: Builder
[ "Remove", "a", "registered", "global", "scope", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L63-L85
230,969
sdispater/orator
orator/orm/builder.py
Builder.find_or_fail
def find_or_fail(self, id, columns=None): """ Find a model by its primary key or raise an exception :param id: The primary key value :type id: mixed :param columns: The columns to retrieve :type columns: list :return: The found model :rtype: orator.Mode...
python
def find_or_fail(self, id, columns=None): """ Find a model by its primary key or raise an exception :param id: The primary key value :type id: mixed :param columns: The columns to retrieve :type columns: list :return: The found model :rtype: orator.Mode...
[ "def", "find_or_fail", "(", "self", ",", "id", ",", "columns", "=", "None", ")", ":", "result", "=", "self", ".", "find", "(", "id", ",", "columns", ")", "if", "isinstance", "(", "id", ",", "list", ")", ":", "if", "len", "(", "result", ")", "==",...
Find a model by its primary key or raise an exception :param id: The primary key value :type id: mixed :param columns: The columns to retrieve :type columns: list :return: The found model :rtype: orator.Model :raises: ModelNotFound
[ "Find", "a", "model", "by", "its", "primary", "key", "or", "raise", "an", "exception" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L143-L166
230,970
sdispater/orator
orator/orm/builder.py
Builder.first_or_fail
def first_or_fail(self, columns=None): """ Execute the query and get the first result or raise an exception :param columns: The columns to get :type columns: list :return: The result :rtype: mixed """ model = self.first(columns) if model is not ...
python
def first_or_fail(self, columns=None): """ Execute the query and get the first result or raise an exception :param columns: The columns to get :type columns: list :return: The result :rtype: mixed """ model = self.first(columns) if model is not ...
[ "def", "first_or_fail", "(", "self", ",", "columns", "=", "None", ")", ":", "model", "=", "self", ".", "first", "(", "columns", ")", "if", "model", "is", "not", "None", ":", "return", "model", "raise", "ModelNotFound", "(", "self", ".", "_model", ".", ...
Execute the query and get the first result or raise an exception :param columns: The columns to get :type columns: list :return: The result :rtype: mixed
[ "Execute", "the", "query", "and", "get", "the", "first", "result", "or", "raise", "an", "exception" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L183-L198
230,971
sdispater/orator
orator/orm/builder.py
Builder.pluck
def pluck(self, column): """ Pluck a single column from the database. :param column: THe column to pluck :type column: str :return: The column value :rtype: mixed """ result = self.first([column]) if result: return result[column]
python
def pluck(self, column): """ Pluck a single column from the database. :param column: THe column to pluck :type column: str :return: The column value :rtype: mixed """ result = self.first([column]) if result: return result[column]
[ "def", "pluck", "(", "self", ",", "column", ")", ":", "result", "=", "self", ".", "first", "(", "[", "column", "]", ")", "if", "result", ":", "return", "result", "[", "column", "]" ]
Pluck a single column from the database. :param column: THe column to pluck :type column: str :return: The column value :rtype: mixed
[ "Pluck", "a", "single", "column", "from", "the", "database", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L221-L234
230,972
sdispater/orator
orator/orm/builder.py
Builder._add_updated_at_column
def _add_updated_at_column(self, values): """ Add the "updated_at" column to a dictionary of values. :param values: The values to update :type values: dict :return: The new dictionary of values :rtype: dict """ if not self._model.uses_timestamps(): ...
python
def _add_updated_at_column(self, values): """ Add the "updated_at" column to a dictionary of values. :param values: The values to update :type values: dict :return: The new dictionary of values :rtype: dict """ if not self._model.uses_timestamps(): ...
[ "def", "_add_updated_at_column", "(", "self", ",", "values", ")", ":", "if", "not", "self", ".", "_model", ".", "uses_timestamps", "(", ")", ":", "return", "values", "column", "=", "self", ".", "_model", ".", "get_updated_at_column", "(", ")", "if", "\"upd...
Add the "updated_at" column to a dictionary of values. :param values: The values to update :type values: dict :return: The new dictionary of values :rtype: dict
[ "Add", "the", "updated_at", "column", "to", "a", "dictionary", "of", "values", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L401-L419
230,973
sdispater/orator
orator/orm/builder.py
Builder.delete
def delete(self): """ Delete a record from the database. """ if self._on_delete is not None: return self._on_delete(self) return self._query.delete()
python
def delete(self): """ Delete a record from the database. """ if self._on_delete is not None: return self._on_delete(self) return self._query.delete()
[ "def", "delete", "(", "self", ")", ":", "if", "self", ".", "_on_delete", "is", "not", "None", ":", "return", "self", ".", "_on_delete", "(", "self", ")", "return", "self", ".", "_query", ".", "delete", "(", ")" ]
Delete a record from the database.
[ "Delete", "a", "record", "from", "the", "database", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L421-L428
230,974
sdispater/orator
orator/orm/builder.py
Builder.get_relation
def get_relation(self, relation): """ Get the relation instance for the given relation name. :rtype: orator.orm.relations.Relation """ from .relations import Relation with Relation.no_constraints(True): rel = getattr(self.get_model(), relation)() ne...
python
def get_relation(self, relation): """ Get the relation instance for the given relation name. :rtype: orator.orm.relations.Relation """ from .relations import Relation with Relation.no_constraints(True): rel = getattr(self.get_model(), relation)() ne...
[ "def", "get_relation", "(", "self", ",", "relation", ")", ":", "from", ".", "relations", "import", "Relation", "with", "Relation", ".", "no_constraints", "(", "True", ")", ":", "rel", "=", "getattr", "(", "self", ".", "get_model", "(", ")", ",", "relatio...
Get the relation instance for the given relation name. :rtype: orator.orm.relations.Relation
[ "Get", "the", "relation", "instance", "for", "the", "given", "relation", "name", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L500-L516
230,975
sdispater/orator
orator/orm/builder.py
Builder._nested_relations
def _nested_relations(self, relation): """ Get the deeply nested relations for a given top-level relation. :rtype: dict """ nested = {} for name, constraints in self._eager_load.items(): if self._is_nested(name, relation): nested[name[len(rel...
python
def _nested_relations(self, relation): """ Get the deeply nested relations for a given top-level relation. :rtype: dict """ nested = {} for name, constraints in self._eager_load.items(): if self._is_nested(name, relation): nested[name[len(rel...
[ "def", "_nested_relations", "(", "self", ",", "relation", ")", ":", "nested", "=", "{", "}", "for", "name", ",", "constraints", "in", "self", ".", "_eager_load", ".", "items", "(", ")", ":", "if", "self", ".", "_is_nested", "(", "name", ",", "relation"...
Get the deeply nested relations for a given top-level relation. :rtype: dict
[ "Get", "the", "deeply", "nested", "relations", "for", "a", "given", "top", "-", "level", "relation", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L518-L530
230,976
sdispater/orator
orator/orm/builder.py
Builder._is_nested
def _is_nested(self, name, relation): """ Determine if the relationship is nested. :type name: str :type relation: str :rtype: bool """ dots = name.find(".") return dots and name.startswith(relation + ".")
python
def _is_nested(self, name, relation): """ Determine if the relationship is nested. :type name: str :type relation: str :rtype: bool """ dots = name.find(".") return dots and name.startswith(relation + ".")
[ "def", "_is_nested", "(", "self", ",", "name", ",", "relation", ")", ":", "dots", "=", "name", ".", "find", "(", "\".\"", ")", "return", "dots", "and", "name", ".", "startswith", "(", "relation", "+", "\".\"", ")" ]
Determine if the relationship is nested. :type name: str :type relation: str :rtype: bool
[ "Determine", "if", "the", "relationship", "is", "nested", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L532-L543
230,977
sdispater/orator
orator/orm/builder.py
Builder.where_exists
def where_exists(self, query, boolean="and", negate=False): """ Add an exists clause to the query. :param query: The exists query :type query: Builder or QueryBuilder :type boolean: str :type negate: bool :rtype: Builder """ if isinstance(query...
python
def where_exists(self, query, boolean="and", negate=False): """ Add an exists clause to the query. :param query: The exists query :type query: Builder or QueryBuilder :type boolean: str :type negate: bool :rtype: Builder """ if isinstance(query...
[ "def", "where_exists", "(", "self", ",", "query", ",", "boolean", "=", "\"and\"", ",", "negate", "=", "False", ")", ":", "if", "isinstance", "(", "query", ",", "Builder", ")", ":", "query", "=", "query", ".", "get_query", "(", ")", "self", ".", "get_...
Add an exists clause to the query. :param query: The exists query :type query: Builder or QueryBuilder :type boolean: str :type negate: bool :rtype: Builder
[ "Add", "an", "exists", "clause", "to", "the", "query", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L589-L607
230,978
sdispater/orator
orator/orm/builder.py
Builder.has
def has(self, relation, operator=">=", count=1, boolean="and", extra=None): """ Add a relationship count condition to the query. :param relation: The relation to count :type relation: str :param operator: The operator :type operator: str :param count: The count...
python
def has(self, relation, operator=">=", count=1, boolean="and", extra=None): """ Add a relationship count condition to the query. :param relation: The relation to count :type relation: str :param operator: The operator :type operator: str :param count: The count...
[ "def", "has", "(", "self", ",", "relation", ",", "operator", "=", "\">=\"", ",", "count", "=", "1", ",", "boolean", "=", "\"and\"", ",", "extra", "=", "None", ")", ":", "if", "relation", ".", "find", "(", "\".\"", ")", ">=", "0", ":", "return", "...
Add a relationship count condition to the query. :param relation: The relation to count :type relation: str :param operator: The operator :type operator: str :param count: The count :type count: int :param boolean: The boolean value :type boolean: str ...
[ "Add", "a", "relationship", "count", "condition", "to", "the", "query", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L646-L683
230,979
sdispater/orator
orator/orm/builder.py
Builder._add_has_where
def _add_has_where(self, has_query, relation, operator, count, boolean): """ Add the "has" condition where clause to the query. :param has_query: The has query :type has_query: Builder :param relation: The relation to count :type relation: orator.orm.relations.Relation ...
python
def _add_has_where(self, has_query, relation, operator, count, boolean): """ Add the "has" condition where clause to the query. :param has_query: The has query :type has_query: Builder :param relation: The relation to count :type relation: orator.orm.relations.Relation ...
[ "def", "_add_has_where", "(", "self", ",", "has_query", ",", "relation", ",", "operator", ",", "count", ",", "boolean", ")", ":", "self", ".", "_merge_model_defined_relation_wheres_to_has_query", "(", "has_query", ",", "relation", ")", "if", "isinstance", "(", "...
Add the "has" condition where clause to the query. :param has_query: The has query :type has_query: Builder :param relation: The relation to count :type relation: orator.orm.relations.Relation :param operator: The operator :type operator: str :param count: The...
[ "Add", "the", "has", "condition", "where", "clause", "to", "the", "query", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L804-L832
230,980
sdispater/orator
orator/orm/builder.py
Builder._merge_model_defined_relation_wheres_to_has_query
def _merge_model_defined_relation_wheres_to_has_query(self, has_query, relation): """ Merge the "wheres" from a relation query to a has query. :param has_query: The has query :type has_query: Builder :param relation: The relation to count :type relation: orator.orm.rela...
python
def _merge_model_defined_relation_wheres_to_has_query(self, has_query, relation): """ Merge the "wheres" from a relation query to a has query. :param has_query: The has query :type has_query: Builder :param relation: The relation to count :type relation: orator.orm.rela...
[ "def", "_merge_model_defined_relation_wheres_to_has_query", "(", "self", ",", "has_query", ",", "relation", ")", ":", "relation_query", "=", "relation", ".", "get_base_query", "(", ")", "has_query", ".", "merge_wheres", "(", "relation_query", ".", "wheres", ",", "re...
Merge the "wheres" from a relation query to a has query. :param has_query: The has query :type has_query: Builder :param relation: The relation to count :type relation: orator.orm.relations.Relation
[ "Merge", "the", "wheres", "from", "a", "relation", "query", "to", "a", "has", "query", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L834-L848
230,981
sdispater/orator
orator/orm/builder.py
Builder.apply_scopes
def apply_scopes(self): """ Get the underlying query builder instance with applied global scopes. :type: Builder """ if not self._scopes: return self builder = copy.copy(self) query = builder.get_query() # We will keep track of how many whe...
python
def apply_scopes(self): """ Get the underlying query builder instance with applied global scopes. :type: Builder """ if not self._scopes: return self builder = copy.copy(self) query = builder.get_query() # We will keep track of how many whe...
[ "def", "apply_scopes", "(", "self", ")", ":", "if", "not", "self", ".", "_scopes", ":", "return", "self", "builder", "=", "copy", ".", "copy", "(", "self", ")", "query", "=", "builder", ".", "get_query", "(", ")", "# We will keep track of how many wheres are...
Get the underlying query builder instance with applied global scopes. :type: Builder
[ "Get", "the", "underlying", "query", "builder", "instance", "with", "applied", "global", "scopes", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L953-L984
230,982
sdispater/orator
orator/orm/builder.py
Builder._apply_scope
def _apply_scope(self, scope, builder): """ Apply a single scope on the given builder instance. :param scope: The scope to apply :type scope: callable or Scope :param builder: The builder to apply the scope to :type builder: Builder """ if callable(scope...
python
def _apply_scope(self, scope, builder): """ Apply a single scope on the given builder instance. :param scope: The scope to apply :type scope: callable or Scope :param builder: The builder to apply the scope to :type builder: Builder """ if callable(scope...
[ "def", "_apply_scope", "(", "self", ",", "scope", ",", "builder", ")", ":", "if", "callable", "(", "scope", ")", ":", "scope", "(", "builder", ")", "elif", "isinstance", "(", "scope", ",", "Scope", ")", ":", "scope", ".", "apply", "(", "builder", ","...
Apply a single scope on the given builder instance. :param scope: The scope to apply :type scope: callable or Scope :param builder: The builder to apply the scope to :type builder: Builder
[ "Apply", "a", "single", "scope", "on", "the", "given", "builder", "instance", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L986-L999
230,983
sdispater/orator
orator/orm/builder.py
Builder._nest_wheres_for_scope
def _nest_wheres_for_scope(self, query, where_counts): """ Nest where conditions of the builder and each global scope. :type query: QueryBuilder :type where_counts: list """ # Here, we totally remove all of the where clauses since we are going to # rebuild them a...
python
def _nest_wheres_for_scope(self, query, where_counts): """ Nest where conditions of the builder and each global scope. :type query: QueryBuilder :type where_counts: list """ # Here, we totally remove all of the where clauses since we are going to # rebuild them a...
[ "def", "_nest_wheres_for_scope", "(", "self", ",", "query", ",", "where_counts", ")", ":", "# Here, we totally remove all of the where clauses since we are going to", "# rebuild them as nested queries by slicing the groups of wheres into", "# their own sections. This is to prevent any confus...
Nest where conditions of the builder and each global scope. :type query: QueryBuilder :type where_counts: list
[ "Nest", "where", "conditions", "of", "the", "builder", "and", "each", "global", "scope", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L1012-L1038
230,984
sdispater/orator
orator/orm/builder.py
Builder._slice_where_conditions
def _slice_where_conditions(self, wheres, offset, length): """ Create a where list with sliced where conditions. :type wheres: list :type offset: int :type length: int :rtype: list """ where_group = self.get_query().for_nested_where() where_group...
python
def _slice_where_conditions(self, wheres, offset, length): """ Create a where list with sliced where conditions. :type wheres: list :type offset: int :type length: int :rtype: list """ where_group = self.get_query().for_nested_where() where_group...
[ "def", "_slice_where_conditions", "(", "self", ",", "wheres", ",", "offset", ",", "length", ")", ":", "where_group", "=", "self", ".", "get_query", "(", ")", ".", "for_nested_where", "(", ")", "where_group", ".", "wheres", "=", "wheres", "[", "offset", ":"...
Create a where list with sliced where conditions. :type wheres: list :type offset: int :type length: int :rtype: list
[ "Create", "a", "where", "list", "with", "sliced", "where", "conditions", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L1040-L1053
230,985
sdispater/orator
orator/orm/builder.py
Builder.set_model
def set_model(self, model): """ Set a model instance for the model being queried. :param model: The model instance :type model: orator.orm.Model :return: The current Builder instance :rtype: Builder """ self._model = model self._query.from_(mode...
python
def set_model(self, model): """ Set a model instance for the model being queried. :param model: The model instance :type model: orator.orm.Model :return: The current Builder instance :rtype: Builder """ self._model = model self._query.from_(mode...
[ "def", "set_model", "(", "self", ",", "model", ")", ":", "self", ".", "_model", "=", "model", "self", ".", "_query", ".", "from_", "(", "model", ".", "get_table", "(", ")", ")", "return", "self" ]
Set a model instance for the model being queried. :param model: The model instance :type model: orator.orm.Model :return: The current Builder instance :rtype: Builder
[ "Set", "a", "model", "instance", "for", "the", "model", "being", "queried", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L1108-L1122
230,986
sdispater/orator
orator/query/grammars/sqlite_grammar.py
SQLiteQueryGrammar.compile_insert
def compile_insert(self, query, values): """ Compile insert statement into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :param values: The insert values :type values: dict or list :return: The compiled insert :rtype: str "...
python
def compile_insert(self, query, values): """ Compile insert statement into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :param values: The insert values :type values: dict or list :return: The compiled insert :rtype: str "...
[ "def", "compile_insert", "(", "self", ",", "query", ",", "values", ")", ":", "table", "=", "self", ".", "wrap_table", "(", "query", ".", "from__", ")", "if", "not", "isinstance", "(", "values", ",", "list", ")", ":", "values", "=", "[", "values", "]"...
Compile insert statement into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :param values: The insert values :type values: dict or list :return: The compiled insert :rtype: str
[ "Compile", "insert", "statement", "into", "SQL" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/grammars/sqlite_grammar.py#L26-L64
230,987
sdispater/orator
orator/query/grammars/sqlite_grammar.py
SQLiteQueryGrammar.compile_truncate
def compile_truncate(self, query): """ Compile a truncate statement into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled truncate statement :rtype: str """ sql = { "DELETE FROM sqlite_sequence WHERE n...
python
def compile_truncate(self, query): """ Compile a truncate statement into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled truncate statement :rtype: str """ sql = { "DELETE FROM sqlite_sequence WHERE n...
[ "def", "compile_truncate", "(", "self", ",", "query", ")", ":", "sql", "=", "{", "\"DELETE FROM sqlite_sequence WHERE name = %s\"", "%", "self", ".", "get_marker", "(", ")", ":", "[", "query", ".", "from__", "]", "}", "sql", "[", "\"DELETE FROM %s\"", "%", "...
Compile a truncate statement into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled truncate statement :rtype: str
[ "Compile", "a", "truncate", "statement", "into", "SQL" ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/grammars/sqlite_grammar.py#L66-L83
230,988
sdispater/orator
orator/schema/blueprint.py
Blueprint.build
def build(self, connection, grammar): """ Execute the blueprint against the database. :param connection: The connection to use :type connection: orator.connections.Connection :param grammar: The grammar to user :type grammar: orator.query.grammars.QueryGrammar "...
python
def build(self, connection, grammar): """ Execute the blueprint against the database. :param connection: The connection to use :type connection: orator.connections.Connection :param grammar: The grammar to user :type grammar: orator.query.grammars.QueryGrammar "...
[ "def", "build", "(", "self", ",", "connection", ",", "grammar", ")", ":", "for", "statement", "in", "self", ".", "to_sql", "(", "connection", ",", "grammar", ")", ":", "connection", ".", "statement", "(", "statement", ")" ]
Execute the blueprint against the database. :param connection: The connection to use :type connection: orator.connections.Connection :param grammar: The grammar to user :type grammar: orator.query.grammars.QueryGrammar
[ "Execute", "the", "blueprint", "against", "the", "database", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L19-L30
230,989
sdispater/orator
orator/schema/blueprint.py
Blueprint.to_sql
def to_sql(self, connection, grammar): """ Get the raw SQL statements for the blueprint. :param connection: The connection to use :type connection: orator.connections.Connection :param grammar: The grammar to user :type grammar: orator.schema.grammars.SchemaGrammar ...
python
def to_sql(self, connection, grammar): """ Get the raw SQL statements for the blueprint. :param connection: The connection to use :type connection: orator.connections.Connection :param grammar: The grammar to user :type grammar: orator.schema.grammars.SchemaGrammar ...
[ "def", "to_sql", "(", "self", ",", "connection", ",", "grammar", ")", ":", "self", ".", "_add_implied_commands", "(", ")", "statements", "=", "[", "]", "for", "command", "in", "self", ".", "_commands", ":", "method", "=", "\"compile_%s\"", "%", "command", ...
Get the raw SQL statements for the blueprint. :param connection: The connection to use :type connection: orator.connections.Connection :param grammar: The grammar to user :type grammar: orator.schema.grammars.SchemaGrammar :rtype: list
[ "Get", "the", "raw", "SQL", "statements", "for", "the", "blueprint", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L32-L59
230,990
sdispater/orator
orator/schema/blueprint.py
Blueprint._add_implied_commands
def _add_implied_commands(self): """ Add the commands that are implied by the blueprint. """ if len(self.get_added_columns()) and not self._creating(): self._commands.insert(0, self._create_command("add")) if len(self.get_changed_columns()) and not self._creating(): ...
python
def _add_implied_commands(self): """ Add the commands that are implied by the blueprint. """ if len(self.get_added_columns()) and not self._creating(): self._commands.insert(0, self._create_command("add")) if len(self.get_changed_columns()) and not self._creating(): ...
[ "def", "_add_implied_commands", "(", "self", ")", ":", "if", "len", "(", "self", ".", "get_added_columns", "(", ")", ")", "and", "not", "self", ".", "_creating", "(", ")", ":", "self", ".", "_commands", ".", "insert", "(", "0", ",", "self", ".", "_cr...
Add the commands that are implied by the blueprint.
[ "Add", "the", "commands", "that", "are", "implied", "by", "the", "blueprint", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L61-L71
230,991
sdispater/orator
orator/schema/blueprint.py
Blueprint.drop_column
def drop_column(self, *columns): """ Indicates that the given columns should be dropped. :param columns: The columns to drop :type columns: tuple :rtype: Fluent """ columns = list(columns) return self._add_command("drop_column", columns=columns)
python
def drop_column(self, *columns): """ Indicates that the given columns should be dropped. :param columns: The columns to drop :type columns: tuple :rtype: Fluent """ columns = list(columns) return self._add_command("drop_column", columns=columns)
[ "def", "drop_column", "(", "self", ",", "*", "columns", ")", ":", "columns", "=", "list", "(", "columns", ")", "return", "self", ".", "_add_command", "(", "\"drop_column\"", ",", "columns", "=", "columns", ")" ]
Indicates that the given columns should be dropped. :param columns: The columns to drop :type columns: tuple :rtype: Fluent
[ "Indicates", "that", "the", "given", "columns", "should", "be", "dropped", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L128-L139
230,992
sdispater/orator
orator/schema/blueprint.py
Blueprint.integer
def integer(self, column, auto_increment=False, unsigned=False): """ Create a new integer column on the table. :param column: The column :type column: str :type auto_increment: bool :type unsigned: bool :rtype: Fluent """ return self._add_colum...
python
def integer(self, column, auto_increment=False, unsigned=False): """ Create a new integer column on the table. :param column: The column :type column: str :type auto_increment: bool :type unsigned: bool :rtype: Fluent """ return self._add_colum...
[ "def", "integer", "(", "self", ",", "column", ",", "auto_increment", "=", "False", ",", "unsigned", "=", "False", ")", ":", "return", "self", ".", "_add_column", "(", "\"integer\"", ",", "column", ",", "auto_increment", "=", "auto_increment", ",", "unsigned"...
Create a new integer column on the table. :param column: The column :type column: str :type auto_increment: bool :type unsigned: bool :rtype: Fluent
[ "Create", "a", "new", "integer", "column", "on", "the", "table", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L358-L373
230,993
sdispater/orator
orator/schema/blueprint.py
Blueprint.small_integer
def small_integer(self, column, auto_increment=False, unsigned=False): """ Create a new small integer column on the table. :param column: The column :type column: str :type auto_increment: bool :type unsigned: bool :rtype: Fluent """ return sel...
python
def small_integer(self, column, auto_increment=False, unsigned=False): """ Create a new small integer column on the table. :param column: The column :type column: str :type auto_increment: bool :type unsigned: bool :rtype: Fluent """ return sel...
[ "def", "small_integer", "(", "self", ",", "column", ",", "auto_increment", "=", "False", ",", "unsigned", "=", "False", ")", ":", "return", "self", ".", "_add_column", "(", "\"small_integer\"", ",", "column", ",", "auto_increment", "=", "auto_increment", ",", ...
Create a new small integer column on the table. :param column: The column :type column: str :type auto_increment: bool :type unsigned: bool :rtype: Fluent
[ "Create", "a", "new", "small", "integer", "column", "on", "the", "table", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L426-L441
230,994
sdispater/orator
orator/schema/blueprint.py
Blueprint.unsigned_integer
def unsigned_integer(self, column, auto_increment=False): """ Create a new unisgned integer column on the table. :param column: The column :type column: str :type auto_increment: bool :rtype: Fluent """ return self.integer(column, auto_increment, True)
python
def unsigned_integer(self, column, auto_increment=False): """ Create a new unisgned integer column on the table. :param column: The column :type column: str :type auto_increment: bool :rtype: Fluent """ return self.integer(column, auto_increment, True)
[ "def", "unsigned_integer", "(", "self", ",", "column", ",", "auto_increment", "=", "False", ")", ":", "return", "self", ".", "integer", "(", "column", ",", "auto_increment", ",", "True", ")" ]
Create a new unisgned integer column on the table. :param column: The column :type column: str :type auto_increment: bool :rtype: Fluent
[ "Create", "a", "new", "unisgned", "integer", "column", "on", "the", "table", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L443-L454
230,995
sdispater/orator
orator/schema/blueprint.py
Blueprint.unsigned_big_integer
def unsigned_big_integer(self, column, auto_increment=False): """ Create a new unsigned big integer column on the table. :param column: The column :type column: str :type auto_increment: bool :rtype: Fluent """ return self.big_integer(column, auto_incre...
python
def unsigned_big_integer(self, column, auto_increment=False): """ Create a new unsigned big integer column on the table. :param column: The column :type column: str :type auto_increment: bool :rtype: Fluent """ return self.big_integer(column, auto_incre...
[ "def", "unsigned_big_integer", "(", "self", ",", "column", ",", "auto_increment", "=", "False", ")", ":", "return", "self", ".", "big_integer", "(", "column", ",", "auto_increment", ",", "True", ")" ]
Create a new unsigned big integer column on the table. :param column: The column :type column: str :type auto_increment: bool :rtype: Fluent
[ "Create", "a", "new", "unsigned", "big", "integer", "column", "on", "the", "table", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L456-L467
230,996
sdispater/orator
orator/schema/blueprint.py
Blueprint.float
def float(self, column, total=8, places=2): """ Create a new float column on the table. :param column: The column :type column: str :type total: int :type places: 2 :rtype: Fluent """ return self._add_column("float", column, total=total, places...
python
def float(self, column, total=8, places=2): """ Create a new float column on the table. :param column: The column :type column: str :type total: int :type places: 2 :rtype: Fluent """ return self._add_column("float", column, total=total, places...
[ "def", "float", "(", "self", ",", "column", ",", "total", "=", "8", ",", "places", "=", "2", ")", ":", "return", "self", ".", "_add_column", "(", "\"float\"", ",", "column", ",", "total", "=", "total", ",", "places", "=", "places", ")" ]
Create a new float column on the table. :param column: The column :type column: str :type total: int :type places: 2 :rtype: Fluent
[ "Create", "a", "new", "float", "column", "on", "the", "table", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L469-L482
230,997
sdispater/orator
orator/schema/blueprint.py
Blueprint.double
def double(self, column, total=None, places=None): """ Create a new double column on the table. :param column: The column :type column: str :type total: int :type places: 2 :rtype: Fluent """ return self._add_column("double", column, total=tota...
python
def double(self, column, total=None, places=None): """ Create a new double column on the table. :param column: The column :type column: str :type total: int :type places: 2 :rtype: Fluent """ return self._add_column("double", column, total=tota...
[ "def", "double", "(", "self", ",", "column", ",", "total", "=", "None", ",", "places", "=", "None", ")", ":", "return", "self", ".", "_add_column", "(", "\"double\"", ",", "column", ",", "total", "=", "total", ",", "places", "=", "places", ")" ]
Create a new double column on the table. :param column: The column :type column: str :type total: int :type places: 2 :rtype: Fluent
[ "Create", "a", "new", "double", "column", "on", "the", "table", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L484-L497
230,998
sdispater/orator
orator/schema/blueprint.py
Blueprint.decimal
def decimal(self, column, total=8, places=2): """ Create a new decimal column on the table. :param column: The column :type column: str :type total: int :type places: 2 :rtype: Fluent """ return self._add_column("decimal", column, total=total, ...
python
def decimal(self, column, total=8, places=2): """ Create a new decimal column on the table. :param column: The column :type column: str :type total: int :type places: 2 :rtype: Fluent """ return self._add_column("decimal", column, total=total, ...
[ "def", "decimal", "(", "self", ",", "column", ",", "total", "=", "8", ",", "places", "=", "2", ")", ":", "return", "self", ".", "_add_column", "(", "\"decimal\"", ",", "column", ",", "total", "=", "total", ",", "places", "=", "places", ")" ]
Create a new decimal column on the table. :param column: The column :type column: str :type total: int :type places: 2 :rtype: Fluent
[ "Create", "a", "new", "decimal", "column", "on", "the", "table", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L499-L512
230,999
sdispater/orator
orator/schema/blueprint.py
Blueprint.timestamps
def timestamps(self, use_current=True): """ Create creation and update timestamps to the table. :rtype: Fluent """ if use_current: self.timestamp("created_at").use_current() self.timestamp("updated_at").use_current() else: self.timesta...
python
def timestamps(self, use_current=True): """ Create creation and update timestamps to the table. :rtype: Fluent """ if use_current: self.timestamp("created_at").use_current() self.timestamp("updated_at").use_current() else: self.timesta...
[ "def", "timestamps", "(", "self", ",", "use_current", "=", "True", ")", ":", "if", "use_current", ":", "self", ".", "timestamp", "(", "\"created_at\"", ")", ".", "use_current", "(", ")", "self", ".", "timestamp", "(", "\"updated_at\"", ")", ".", "use_curre...
Create creation and update timestamps to the table. :rtype: Fluent
[ "Create", "creation", "and", "update", "timestamps", "to", "the", "table", "." ]
bd90bf198ee897751848f9a92e49d18e60a74136
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L602-L613