repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
sdispater/eloquent
eloquent/migrations/database_migration_repository.py
DatabaseMigrationRepository.get_last
def get_last(self): """ Get the last migration batch. :rtype: list """ query = self.table().where('batch', self.get_last_batch_number()) return query.order_by('migration', 'desc').get()
python
def get_last(self): """ Get the last migration batch. :rtype: list """ query = self.table().where('batch', self.get_last_batch_number()) return query.order_by('migration', 'desc').get()
[ "def", "get_last", "(", "self", ")", ":", "query", "=", "self", ".", "table", "(", ")", ".", "where", "(", "'batch'", ",", "self", ".", "get_last_batch_number", "(", ")", ")", "return", "query", ".", "order_by", "(", "'migration'", ",", "'desc'", ")", ...
Get the last migration batch. :rtype: list
[ "Get", "the", "last", "migration", "batch", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/migrations/database_migration_repository.py#L25-L33
sdispater/eloquent
eloquent/query/grammars/grammar.py
QueryGrammar.compile_insert
def compile_insert(self, query, values): """ Compile an insert SQL statement :param query: A QueryBuilder instance :type query: QueryBuilder :param values: The values to insert :type values: dict or list :return: The compiled statement :rtype: str ...
python
def compile_insert(self, query, values): """ Compile an insert SQL statement :param query: A QueryBuilder instance :type query: QueryBuilder :param values: The values to insert :type values: dict or list :return: The compiled statement :rtype: str ...
[ "def", "compile_insert", "(", "self", ",", "query", ",", "values", ")", ":", "# Essentially we will force every insert to be treated as a batch insert which", "# simply makes creating the SQL easier for us since we can utilize the same", "# basic routine regardless of an amount of records gi...
Compile an insert SQL statement :param query: A QueryBuilder instance :type query: QueryBuilder :param values: The values to insert :type values: dict or list :return: The compiled statement :rtype: str
[ "Compile", "an", "insert", "SQL", "statement" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/grammars/grammar.py#L312-L344
sdispater/eloquent
eloquent/dbal/platforms/postgres_platform.py
PostgresPlatform.get_alter_table_sql
def get_alter_table_sql(self, diff): """ Get the ALTER TABLE SQL statement :param diff: The table diff :type diff: eloquent.dbal.table_diff.TableDiff :rtype: list """ sql = [] for column_diff in diff.changed_columns.values(): if self.is_unch...
python
def get_alter_table_sql(self, diff): """ Get the ALTER TABLE SQL statement :param diff: The table diff :type diff: eloquent.dbal.table_diff.TableDiff :rtype: list """ sql = [] for column_diff in diff.changed_columns.values(): if self.is_unch...
[ "def", "get_alter_table_sql", "(", "self", ",", "diff", ")", ":", "sql", "=", "[", "]", "for", "column_diff", "in", "diff", ".", "changed_columns", ".", "values", "(", ")", ":", "if", "self", ".", "is_unchanged_binary_column", "(", "column_diff", ")", ":",...
Get the ALTER TABLE SQL statement :param diff: The table diff :type diff: eloquent.dbal.table_diff.TableDiff :rtype: list
[ "Get", "the", "ALTER", "TABLE", "SQL", "statement" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/dbal/platforms/postgres_platform.py#L117-L180
sdispater/eloquent
eloquent/query/grammars/sqlite_grammar.py
SQLiteQueryGrammar._date_based_where
def _date_based_where(self, type, query, where): """ Compiled a date where based clause :param type: The date type :type type: str :param query: A QueryBuilder instance :type query: QueryBuilder :param where: The condition :type where: dict :re...
python
def _date_based_where(self, type, query, where): """ Compiled a date where based clause :param type: The date type :type type: str :param query: A QueryBuilder instance :type query: QueryBuilder :param where: The condition :type where: dict :re...
[ "def", "_date_based_where", "(", "self", ",", "type", ",", "query", ",", "where", ")", ":", "value", "=", "str", "(", "where", "[", "'value'", "]", ")", ".", "zfill", "(", "2", ")", "value", "=", "self", ".", "parameter", "(", "value", ")", "return...
Compiled a date where based clause :param type: The date type :type type: str :param query: A QueryBuilder instance :type query: QueryBuilder :param where: The condition :type where: dict :return: The compiled clause :rtype: str
[ "Compiled", "a", "date", "where", "based", "clause" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/grammars/sqlite_grammar.py#L114-L135
sdispater/eloquent
eloquent/query/grammars/mysql_grammar.py
MySqlQueryGrammar.compile_select
def compile_select(self, query): """ Compile a select query into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled sql :rtype: str """ sql = super(MySqlQueryGrammar, self).compile_select(query) if query.un...
python
def compile_select(self, query): """ Compile a select query into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled sql :rtype: str """ sql = super(MySqlQueryGrammar, self).compile_select(query) if query.un...
[ "def", "compile_select", "(", "self", ",", "query", ")", ":", "sql", "=", "super", "(", "MySqlQueryGrammar", ",", "self", ")", ".", "compile_select", "(", "query", ")", "if", "query", ".", "unions", ":", "sql", "=", "'(%s) %s'", "%", "(", "sql", ",", ...
Compile a select query into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :return: The compiled sql :rtype: str
[ "Compile", "a", "select", "query", "into", "SQL" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/grammars/mysql_grammar.py#L23-L38
sdispater/eloquent
eloquent/query/grammars/mysql_grammar.py
MySqlQueryGrammar._compile_lock
def _compile_lock(self, query, value): """ Compile the lock into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :param value: The lock value :type value: bool or str :return: The compiled lock :rtype: str """ if isin...
python
def _compile_lock(self, query, value): """ Compile the lock into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :param value: The lock value :type value: bool or str :return: The compiled lock :rtype: str """ if isin...
[ "def", "_compile_lock", "(", "self", ",", "query", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "basestring", ")", ":", "return", "value", "if", "value", "is", "True", ":", "return", "'FOR UPDATE'", "elif", "value", "is", "False", ":", ...
Compile the lock into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :param value: The lock value :type value: bool or str :return: The compiled lock :rtype: str
[ "Compile", "the", "lock", "into", "SQL" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/grammars/mysql_grammar.py#L57-L76
sdispater/eloquent
eloquent/query/grammars/mysql_grammar.py
MySqlQueryGrammar.compile_update
def compile_update(self, query, values): """ Compile an update statement into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :param values: The update values :type values: dict :return: The compiled update :rtype: str """ ...
python
def compile_update(self, query, values): """ Compile an update statement into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :param values: The update values :type values: dict :return: The compiled update :rtype: str """ ...
[ "def", "compile_update", "(", "self", ",", "query", ",", "values", ")", ":", "sql", "=", "super", "(", "MySqlQueryGrammar", ",", "self", ")", ".", "compile_update", "(", "query", ",", "values", ")", "if", "query", ".", "orders", ":", "sql", "+=", "' %s...
Compile an update statement into SQL :param query: A QueryBuilder instance :type query: QueryBuilder :param values: The update values :type values: dict :return: The compiled update :rtype: str
[ "Compile", "an", "update", "statement", "into", "SQL" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/grammars/mysql_grammar.py#L78-L99
sdispater/eloquent
eloquent/support/collection.py
Collection.collapse
def collapse(self): """ Collapse the collection items into a single element (dict or list) :return: A new Collection instance with collapsed items :rtype: Collection """ results = [] if isinstance(self._items, dict): items = self._items.values() ...
python
def collapse(self): """ Collapse the collection items into a single element (dict or list) :return: A new Collection instance with collapsed items :rtype: Collection """ results = [] if isinstance(self._items, dict): items = self._items.values() ...
[ "def", "collapse", "(", "self", ")", ":", "results", "=", "[", "]", "if", "isinstance", "(", "self", ".", "_items", ",", "dict", ")", ":", "items", "=", "self", ".", "_items", ".", "values", "(", ")", "for", "values", "in", "items", ":", "if", "i...
Collapse the collection items into a single element (dict or list) :return: A new Collection instance with collapsed items :rtype: Collection
[ "Collapse", "the", "collection", "items", "into", "a", "single", "element", "(", "dict", "or", "list", ")" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/support/collection.py#L50-L68
sdispater/eloquent
eloquent/support/collection.py
Collection.contains
def contains(self, key, value=None): """ Determine if an element is in the collection :param key: The element :type key: int or str :param value: The value of the element :type value: mixed :return: Whether the element is in the collection :rtype: bool ...
python
def contains(self, key, value=None): """ Determine if an element is in the collection :param key: The element :type key: int or str :param value: The value of the element :type value: mixed :return: Whether the element is in the collection :rtype: bool ...
[ "def", "contains", "(", "self", ",", "key", ",", "value", "=", "None", ")", ":", "if", "value", "is", "not", "None", ":", "if", "isinstance", "(", "self", ".", "_items", ",", "list", ")", ":", "return", "key", "in", "self", ".", "_items", "and", ...
Determine if an element is in the collection :param key: The element :type key: int or str :param value: The value of the element :type value: mixed :return: Whether the element is in the collection :rtype: bool
[ "Determine", "if", "an", "element", "is", "in", "the", "collection" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/support/collection.py#L70-L89
sdispater/eloquent
eloquent/support/collection.py
Collection.lists
def lists(self, value, key=None): """ Get a list with the values of a given key :rtype: list """ results = map(lambda x: x[value], self._items) return list(results)
python
def lists(self, value, key=None): """ Get a list with the values of a given key :rtype: list """ results = map(lambda x: x[value], self._items) return list(results)
[ "def", "lists", "(", "self", ",", "value", ",", "key", "=", "None", ")", ":", "results", "=", "map", "(", "lambda", "x", ":", "x", "[", "value", "]", ",", "self", ".", "_items", ")", "return", "list", "(", "results", ")" ]
Get a list with the values of a given key :rtype: list
[ "Get", "a", "list", "with", "the", "values", "of", "a", "given", "key" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/support/collection.py#L118-L126
sdispater/eloquent
eloquent/support/collection.py
Collection.map
def map(self, callback): """ Run a map over each of the item. :param callback: The map function :type callback: callable :rtype: Collection """ if isinstance(self._items, dict): return Collection(list(map(callback, self._items.values()))) re...
python
def map(self, callback): """ Run a map over each of the item. :param callback: The map function :type callback: callable :rtype: Collection """ if isinstance(self._items, dict): return Collection(list(map(callback, self._items.values()))) re...
[ "def", "map", "(", "self", ",", "callback", ")", ":", "if", "isinstance", "(", "self", ".", "_items", ",", "dict", ")", ":", "return", "Collection", "(", "list", "(", "map", "(", "callback", ",", "self", ".", "_items", ".", "values", "(", ")", ")",...
Run a map over each of the item. :param callback: The map function :type callback: callable :rtype: Collection
[ "Run", "a", "map", "over", "each", "of", "the", "item", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/support/collection.py#L128-L140
sdispater/eloquent
eloquent/support/collection.py
Collection.unique
def unique(self): """ Return only unique items from the collection list. :rtype: Collection """ seen = set() seen_add = seen.add return Collection([x for x in self._items if not (x in seen or seen_add(x))])
python
def unique(self): """ Return only unique items from the collection list. :rtype: Collection """ seen = set() seen_add = seen.add return Collection([x for x in self._items if not (x in seen or seen_add(x))])
[ "def", "unique", "(", "self", ")", ":", "seen", "=", "set", "(", ")", "seen_add", "=", "seen", ".", "add", "return", "Collection", "(", "[", "x", "for", "x", "in", "self", ".", "_items", "if", "not", "(", "x", "in", "seen", "or", "seen_add", "(",...
Return only unique items from the collection list. :rtype: Collection
[ "Return", "only", "unique", "items", "from", "the", "collection", "list", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/support/collection.py#L142-L151
sdispater/eloquent
eloquent/orm/collection.py
Collection.load
def load(self, *relations): """ Load a set of relationships onto the collection. """ if len(self._items) > 0: query = self.first().new_query().with_(*relations) self._items = query.eager_load_relations(self._items) return self
python
def load(self, *relations): """ Load a set of relationships onto the collection. """ if len(self._items) > 0: query = self.first().new_query().with_(*relations) self._items = query.eager_load_relations(self._items) return self
[ "def", "load", "(", "self", ",", "*", "relations", ")", ":", "if", "len", "(", "self", ".", "_items", ")", ">", "0", ":", "query", "=", "self", ".", "first", "(", ")", ".", "new_query", "(", ")", ".", "with_", "(", "*", "relations", ")", "self"...
Load a set of relationships onto the collection.
[ "Load", "a", "set", "of", "relationships", "onto", "the", "collection", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/collection.py#L8-L17
sdispater/eloquent
eloquent/schema/grammars/grammar.py
SchemaGrammar.compile_foreign
def compile_foreign(self, blueprint, command, _): """ Compile a foreign key command. :param blueprint: The blueprint :type blueprint: Blueprint :param command: The command :type command: Fluent :rtype: str """ table = self.wrap_table(blueprint) ...
python
def compile_foreign(self, blueprint, command, _): """ Compile a foreign key command. :param blueprint: The blueprint :type blueprint: Blueprint :param command: The command :type command: Fluent :rtype: str """ table = self.wrap_table(blueprint) ...
[ "def", "compile_foreign", "(", "self", ",", "blueprint", ",", "command", ",", "_", ")", ":", "table", "=", "self", ".", "wrap_table", "(", "blueprint", ")", "on", "=", "self", ".", "wrap_table", "(", "command", ".", "on", ")", "columns", "=", "self", ...
Compile a foreign key command. :param blueprint: The blueprint :type blueprint: Blueprint :param command: The command :type command: Fluent :rtype: str
[ "Compile", "a", "foreign", "key", "command", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/schema/grammars/grammar.py#L73-L105
sdispater/eloquent
eloquent/schema/grammars/grammar.py
SchemaGrammar._get_columns
def _get_columns(self, blueprint): """ Get the blueprint's columns definitions. :param blueprint: The blueprint :type blueprint: Blueprint :rtype: list """ columns = [] for column in blueprint.get_added_columns(): sql = self.wrap(column) + '...
python
def _get_columns(self, blueprint): """ Get the blueprint's columns definitions. :param blueprint: The blueprint :type blueprint: Blueprint :rtype: list """ columns = [] for column in blueprint.get_added_columns(): sql = self.wrap(column) + '...
[ "def", "_get_columns", "(", "self", ",", "blueprint", ")", ":", "columns", "=", "[", "]", "for", "column", "in", "blueprint", ".", "get_added_columns", "(", ")", ":", "sql", "=", "self", ".", "wrap", "(", "column", ")", "+", "' '", "+", "self", ".", ...
Get the blueprint's columns definitions. :param blueprint: The blueprint :type blueprint: Blueprint :rtype: list
[ "Get", "the", "blueprint", "s", "columns", "definitions", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/schema/grammars/grammar.py#L107-L123
sdispater/eloquent
eloquent/schema/grammars/grammar.py
SchemaGrammar._add_modifiers
def _add_modifiers(self, sql, blueprint, column): """ Add the column modifiers to the deifinition """ for modifier in self._modifiers: method = '_modify_%s' % modifier if hasattr(self, method): sql += getattr(self, method)(blueprint, column) ...
python
def _add_modifiers(self, sql, blueprint, column): """ Add the column modifiers to the deifinition """ for modifier in self._modifiers: method = '_modify_%s' % modifier if hasattr(self, method): sql += getattr(self, method)(blueprint, column) ...
[ "def", "_add_modifiers", "(", "self", ",", "sql", ",", "blueprint", ",", "column", ")", ":", "for", "modifier", "in", "self", ".", "_modifiers", ":", "method", "=", "'_modify_%s'", "%", "modifier", "if", "hasattr", "(", "self", ",", "method", ")", ":", ...
Add the column modifiers to the deifinition
[ "Add", "the", "column", "modifiers", "to", "the", "deifinition" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/schema/grammars/grammar.py#L125-L135
sdispater/eloquent
eloquent/orm/relations/belongs_to_many.py
BelongsToMany._clean_pivot_attributes
def _clean_pivot_attributes(self, model): """ Get the pivot attributes from a model. :type model: eloquent.Model """ values = {} delete_keys = [] for key, value in model.get_attributes().items(): if key.find('pivot_') == 0: values[key...
python
def _clean_pivot_attributes(self, model): """ Get the pivot attributes from a model. :type model: eloquent.Model """ values = {} delete_keys = [] for key, value in model.get_attributes().items(): if key.find('pivot_') == 0: values[key...
[ "def", "_clean_pivot_attributes", "(", "self", ",", "model", ")", ":", "values", "=", "{", "}", "delete_keys", "=", "[", "]", "for", "key", ",", "value", "in", "model", ".", "get_attributes", "(", ")", ".", "items", "(", ")", ":", "if", "key", ".", ...
Get the pivot attributes from a model. :type model: eloquent.Model
[ "Get", "the", "pivot", "attributes", "from", "a", "model", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/belongs_to_many.py#L155-L173
sdispater/eloquent
eloquent/orm/relations/belongs_to_many.py
BelongsToMany.get_relation_count_query_for_self_join
def get_relation_count_query_for_self_join(self, query, parent): """ Add the constraints for a relationship count query on the same table. :type query: eloquent.orm.Builder :type parent: eloquent.orm.Builder :rtype: eloquent.orm.Builder """ query.select(QueryExp...
python
def get_relation_count_query_for_self_join(self, query, parent): """ Add the constraints for a relationship count query on the same table. :type query: eloquent.orm.Builder :type parent: eloquent.orm.Builder :rtype: eloquent.orm.Builder """ query.select(QueryExp...
[ "def", "get_relation_count_query_for_self_join", "(", "self", ",", "query", ",", "parent", ")", ":", "query", ".", "select", "(", "QueryExpression", "(", "'COUNT(*)'", ")", ")", "table_prefix", "=", "self", ".", "_query", ".", "get_query", "(", ")", ".", "ge...
Add the constraints for a relationship count query on the same table. :type query: eloquent.orm.Builder :type parent: eloquent.orm.Builder :rtype: eloquent.orm.Builder
[ "Add", "the", "constraints", "for", "a", "relationship", "count", "query", "on", "the", "same", "table", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/belongs_to_many.py#L202-L220
sdispater/eloquent
eloquent/orm/relations/belongs_to_many.py
BelongsToMany._get_select_columns
def _get_select_columns(self, columns=None): """ Set the select clause for the relation query. :param columns: The columns :type columns: list :rtype: list """ if columns == ['*'] or columns is None: columns = ['%s.*' % self._related.get_table()] ...
python
def _get_select_columns(self, columns=None): """ Set the select clause for the relation query. :param columns: The columns :type columns: list :rtype: list """ if columns == ['*'] or columns is None: columns = ['%s.*' % self._related.get_table()] ...
[ "def", "_get_select_columns", "(", "self", ",", "columns", "=", "None", ")", ":", "if", "columns", "==", "[", "'*'", "]", "or", "columns", "is", "None", ":", "columns", "=", "[", "'%s.*'", "%", "self", ".", "_related", ".", "get_table", "(", ")", "]"...
Set the select clause for the relation query. :param columns: The columns :type columns: list :rtype: list
[ "Set", "the", "select", "clause", "for", "the", "relation", "query", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/belongs_to_many.py#L230-L242
sdispater/eloquent
eloquent/orm/relations/belongs_to_many.py
BelongsToMany._get_aliased_pivot_columns
def _get_aliased_pivot_columns(self): """ Get the pivot columns for the relation. :rtype: list """ defaults = [self._foreign_key, self._other_key] columns = [] for column in defaults + self._pivot_columns: value = '%s.%s AS pivot_%s' % (self._table,...
python
def _get_aliased_pivot_columns(self): """ Get the pivot columns for the relation. :rtype: list """ defaults = [self._foreign_key, self._other_key] columns = [] for column in defaults + self._pivot_columns: value = '%s.%s AS pivot_%s' % (self._table,...
[ "def", "_get_aliased_pivot_columns", "(", "self", ")", ":", "defaults", "=", "[", "self", ".", "_foreign_key", ",", "self", ".", "_other_key", "]", "columns", "=", "[", "]", "for", "column", "in", "defaults", "+", "self", ".", "_pivot_columns", ":", "value...
Get the pivot columns for the relation. :rtype: list
[ "Get", "the", "pivot", "columns", "for", "the", "relation", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/belongs_to_many.py#L244-L259
sdispater/eloquent
eloquent/orm/relations/belongs_to_many.py
BelongsToMany._set_join
def _set_join(self, query=None): """ Set the join clause for the relation query. :param query: The query builder :type query: eloquent.orm.Builder :return: self :rtype: BelongsToMany """ if not query: query = self._query base_table =...
python
def _set_join(self, query=None): """ Set the join clause for the relation query. :param query: The query builder :type query: eloquent.orm.Builder :return: self :rtype: BelongsToMany """ if not query: query = self._query base_table =...
[ "def", "_set_join", "(", "self", ",", "query", "=", "None", ")", ":", "if", "not", "query", ":", "query", "=", "self", ".", "_query", "base_table", "=", "self", ".", "_related", ".", "get_table", "(", ")", "key", "=", "'%s.%s'", "%", "(", "base_table...
Set the join clause for the relation query. :param query: The query builder :type query: eloquent.orm.Builder :return: self :rtype: BelongsToMany
[ "Set", "the", "join", "clause", "for", "the", "relation", "query", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/belongs_to_many.py#L272-L291
sdispater/eloquent
eloquent/orm/relations/belongs_to_many.py
BelongsToMany.match
def match(self, models, results, relation): """ Match the eagerly loaded results to their parents. :type models: list :type results: Collection :type relation: str """ dictionary = self._build_dictionary(results) for model in models: key = m...
python
def match(self, models, results, relation): """ Match the eagerly loaded results to their parents. :type models: list :type results: Collection :type relation: str """ dictionary = self._build_dictionary(results) for model in models: key = m...
[ "def", "match", "(", "self", ",", "models", ",", "results", ",", "relation", ")", ":", "dictionary", "=", "self", ".", "_build_dictionary", "(", "results", ")", "for", "model", "in", "models", ":", "key", "=", "model", ".", "get_key", "(", ")", "if", ...
Match the eagerly loaded results to their parents. :type models: list :type results: Collection :type relation: str
[ "Match", "the", "eagerly", "loaded", "results", "to", "their", "parents", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/belongs_to_many.py#L326-L344
sdispater/eloquent
eloquent/orm/relations/belongs_to_many.py
BelongsToMany.save
def save(self, model, joining=None, touch=True): """ Save a new model and attach it to the parent model. :type model: eloquent.Model :type joining: dict :type touch: bool :rtype: eloquent.Model """ if joining is None: joining = {} mo...
python
def save(self, model, joining=None, touch=True): """ Save a new model and attach it to the parent model. :type model: eloquent.Model :type joining: dict :type touch: bool :rtype: eloquent.Model """ if joining is None: joining = {} mo...
[ "def", "save", "(", "self", ",", "model", ",", "joining", "=", "None", ",", "touch", "=", "True", ")", ":", "if", "joining", "is", "None", ":", "joining", "=", "{", "}", "model", ".", "save", "(", "{", "'touch'", ":", "False", "}", ")", "self", ...
Save a new model and attach it to the parent model. :type model: eloquent.Model :type joining: dict :type touch: bool :rtype: eloquent.Model
[ "Save", "a", "new", "model", "and", "attach", "it", "to", "the", "parent", "model", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/belongs_to_many.py#L393-L410
sdispater/eloquent
eloquent/orm/relations/belongs_to_many.py
BelongsToMany._attach_new
def _attach_new(self, records, current, touch=True): """ Attach all of the IDs that aren't in the current dict. """ changes = { 'attached': [], 'updated': [] } for id, attributes in records.items(): if id not in current: ...
python
def _attach_new(self, records, current, touch=True): """ Attach all of the IDs that aren't in the current dict. """ changes = { 'attached': [], 'updated': [] } for id, attributes in records.items(): if id not in current: ...
[ "def", "_attach_new", "(", "self", ",", "records", ",", "current", ",", "touch", "=", "True", ")", ":", "changes", "=", "{", "'attached'", ":", "[", "]", ",", "'updated'", ":", "[", "]", "}", "for", "id", ",", "attributes", "in", "records", ".", "i...
Attach all of the IDs that aren't in the current dict.
[ "Attach", "all", "of", "the", "IDs", "that", "aren", "t", "in", "the", "current", "dict", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/belongs_to_many.py#L595-L612
sdispater/eloquent
eloquent/orm/relations/belongs_to_many.py
BelongsToMany.update_existing_pivot
def update_existing_pivot(self, id, attributes, touch=True): """ Update an existing pivot record on the table. """ if self.updated_at() in self._pivot_columns: attributes = self.set_timestamps_on_attach(attributes, True) updated = self._new_picot_statement_for_id(id)...
python
def update_existing_pivot(self, id, attributes, touch=True): """ Update an existing pivot record on the table. """ if self.updated_at() in self._pivot_columns: attributes = self.set_timestamps_on_attach(attributes, True) updated = self._new_picot_statement_for_id(id)...
[ "def", "update_existing_pivot", "(", "self", ",", "id", ",", "attributes", ",", "touch", "=", "True", ")", ":", "if", "self", ".", "updated_at", "(", ")", "in", "self", ".", "_pivot_columns", ":", "attributes", "=", "self", ".", "set_timestamps_on_attach", ...
Update an existing pivot record on the table.
[ "Update", "an", "existing", "pivot", "record", "on", "the", "table", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/belongs_to_many.py#L614-L626
sdispater/eloquent
eloquent/connections/connection.py
Connection.query
def query(self): """ Begin a fluent query :return: A QueryBuilder instance :rtype: QueryBuilder """ query = QueryBuilder(self, self._query_grammar, self._post_processor) return query
python
def query(self): """ Begin a fluent query :return: A QueryBuilder instance :rtype: QueryBuilder """ query = QueryBuilder(self, self._query_grammar, self._post_processor) return query
[ "def", "query", "(", "self", ")", ":", "query", "=", "QueryBuilder", "(", "self", ",", "self", ".", "_query_grammar", ",", "self", ".", "_post_processor", ")", "return", "query" ]
Begin a fluent query :return: A QueryBuilder instance :rtype: QueryBuilder
[ "Begin", "a", "fluent", "query" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/connections/connection.py#L108-L117
sdispater/eloquent
eloquent/orm/mixins/soft_deletes.py
SoftDeletes.force_delete
def force_delete(self): """ Force a hard delete on a soft deleted model. """ self._force_deleting = True self.delete() self._force_deleting = False
python
def force_delete(self): """ Force a hard delete on a soft deleted model. """ self._force_deleting = True self.delete() self._force_deleting = False
[ "def", "force_delete", "(", "self", ")", ":", "self", ".", "_force_deleting", "=", "True", "self", ".", "delete", "(", ")", "self", ".", "_force_deleting", "=", "False" ]
Force a hard delete on a soft deleted model.
[ "Force", "a", "hard", "delete", "on", "a", "soft", "deleted", "model", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/mixins/soft_deletes.py#L17-L25
sdispater/eloquent
eloquent/orm/mixins/soft_deletes.py
SoftDeletes._do_perform_delete_on_model
def _do_perform_delete_on_model(self): """ Perform the actual delete query on this model instance. """ if self._force_deleting: return self.with_trashed().where(self.get_key_name(), self.get_key()).force_delete() return self._run_soft_delete()
python
def _do_perform_delete_on_model(self): """ Perform the actual delete query on this model instance. """ if self._force_deleting: return self.with_trashed().where(self.get_key_name(), self.get_key()).force_delete() return self._run_soft_delete()
[ "def", "_do_perform_delete_on_model", "(", "self", ")", ":", "if", "self", ".", "_force_deleting", ":", "return", "self", ".", "with_trashed", "(", ")", ".", "where", "(", "self", ".", "get_key_name", "(", ")", ",", "self", ".", "get_key", "(", ")", ")",...
Perform the actual delete query on this model instance.
[ "Perform", "the", "actual", "delete", "query", "on", "this", "model", "instance", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/mixins/soft_deletes.py#L27-L34
sdispater/eloquent
eloquent/orm/mixins/soft_deletes.py
SoftDeletes.restore
def restore(self): """ Restore a soft-deleted model instance. """ setattr(self, self.get_deleted_at_column(), None) self.set_exists(True) result = self.save() return result
python
def restore(self): """ Restore a soft-deleted model instance. """ setattr(self, self.get_deleted_at_column(), None) self.set_exists(True) result = self.save() return result
[ "def", "restore", "(", "self", ")", ":", "setattr", "(", "self", ",", "self", ".", "get_deleted_at_column", "(", ")", ",", "None", ")", "self", ".", "set_exists", "(", "True", ")", "result", "=", "self", ".", "save", "(", ")", "return", "result" ]
Restore a soft-deleted model instance.
[ "Restore", "a", "soft", "-", "deleted", "model", "instance", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/mixins/soft_deletes.py#L49-L59
sdispater/eloquent
eloquent/query/builder.py
QueryBuilder.join
def join(self, table, one=None, operator=None, two=None, type='inner', where=False): """ Add a join clause to the query :param table: The table to join with, can also be a JoinClause instance :type table: str or JoinClause :param one: The first column of the join c...
python
def join(self, table, one=None, operator=None, two=None, type='inner', where=False): """ Add a join clause to the query :param table: The table to join with, can also be a JoinClause instance :type table: str or JoinClause :param one: The first column of the join c...
[ "def", "join", "(", "self", ",", "table", ",", "one", "=", "None", ",", "operator", "=", "None", ",", "two", "=", "None", ",", "type", "=", "'inner'", ",", "where", "=", "False", ")", ":", "if", "isinstance", "(", "table", ",", "JoinClause", ")", ...
Add a join clause to the query :param table: The table to join with, can also be a JoinClause instance :type table: str or JoinClause :param one: The first column of the join condition :type one: str :param operator: The operator of the join condition :type operator: s...
[ "Add", "a", "join", "clause", "to", "the", "query" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/builder.py#L168-L206
sdispater/eloquent
eloquent/query/builder.py
QueryBuilder.join_where
def join_where(self, table, one, operator, two, type='inner'): """ Add a "join where" clause to the query :param table: The table to join with, can also be a JoinClause instance :type table: str or JoinClause :param one: The first column of the join condition :type one:...
python
def join_where(self, table, one, operator, two, type='inner'): """ Add a "join where" clause to the query :param table: The table to join with, can also be a JoinClause instance :type table: str or JoinClause :param one: The first column of the join condition :type one:...
[ "def", "join_where", "(", "self", ",", "table", ",", "one", ",", "operator", ",", "two", ",", "type", "=", "'inner'", ")", ":", "return", "self", ".", "join", "(", "table", ",", "one", ",", "operator", ",", "two", ",", "type", ",", "True", ")" ]
Add a "join where" clause to the query :param table: The table to join with, can also be a JoinClause instance :type table: str or JoinClause :param one: The first column of the join condition :type one: str :param operator: The operator of the join condition :type ope...
[ "Add", "a", "join", "where", "clause", "to", "the", "query" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/builder.py#L208-L230
sdispater/eloquent
eloquent/query/builder.py
QueryBuilder._where_in_sub
def _where_in_sub(self, column, query, boolean, negate=False): """ Add a where in with a sub select to the query :param column: The column :type column: str :param query: A QueryBuilder instance :type query: QueryBuilder :param boolean: The boolean operator ...
python
def _where_in_sub(self, column, query, boolean, negate=False): """ Add a where in with a sub select to the query :param column: The column :type column: str :param query: A QueryBuilder instance :type query: QueryBuilder :param boolean: The boolean operator ...
[ "def", "_where_in_sub", "(", "self", ",", "column", ",", "query", ",", "boolean", ",", "negate", "=", "False", ")", ":", "if", "negate", ":", "type", "=", "'not_in_sub'", "else", ":", "type", "=", "'in_sub'", "self", ".", "wheres", ".", "append", "(", ...
Add a where in with a sub select to the query :param column: The column :type column: str :param query: A QueryBuilder instance :type query: QueryBuilder :param boolean: The boolean operator :type boolean: str :param negate: Whether it is a not where in ...
[ "Add", "a", "where", "in", "with", "a", "sub", "select", "to", "the", "query" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/builder.py#L521-L554
sdispater/eloquent
eloquent/query/builder.py
QueryBuilder.or_having
def or_having(self, column, operator=None, value=None): """ Add a "having" clause to the query :param column: The column :type column: str :param operator: The having clause operator :type operator: str :param value: The having clause value :type value:...
python
def or_having(self, column, operator=None, value=None): """ Add a "having" clause to the query :param column: The column :type column: str :param operator: The having clause operator :type operator: str :param value: The having clause value :type value:...
[ "def", "or_having", "(", "self", ",", "column", ",", "operator", "=", "None", ",", "value", "=", "None", ")", ":", "return", "self", ".", "having", "(", "column", ",", "operator", ",", "value", ",", "'or'", ")" ]
Add a "having" clause to the query :param column: The column :type column: str :param operator: The having clause operator :type operator: str :param value: The having clause value :type value: mixed :return: The current QueryBuilder instance :rtype: Q...
[ "Add", "a", "having", "clause", "to", "the", "query" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/builder.py#L676-L692
sdispater/eloquent
eloquent/query/builder.py
QueryBuilder.union
def union(self, query, all=False): """ Add a union statement to the query :param query: A QueryBuilder instance :type query: QueryBuilder :param all: Whether it is a "union all" statement :type all: bool :return: The query :rtype: QueryBuilder "...
python
def union(self, query, all=False): """ Add a union statement to the query :param query: A QueryBuilder instance :type query: QueryBuilder :param all: Whether it is a "union all" statement :type all: bool :return: The query :rtype: QueryBuilder "...
[ "def", "union", "(", "self", ",", "query", ",", "all", "=", "False", ")", ":", "self", ".", "unions", ".", "append", "(", "{", "'query'", ":", "query", ",", "'all'", ":", "all", "}", ")", "return", "self", ".", "merge_bindings", "(", "query", ")" ]
Add a union statement to the query :param query: A QueryBuilder instance :type query: QueryBuilder :param all: Whether it is a "union all" statement :type all: bool :return: The query :rtype: QueryBuilder
[ "Add", "a", "union", "statement", "to", "the", "query" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/builder.py#L850-L868
sdispater/eloquent
eloquent/query/builder.py
QueryBuilder.find
def find(self, id, columns=None): """ Execute a query for a single record by id :param id: The id of the record to retrieve :type id: mixed :param columns: The columns of the record to retrive :type columns: list :return: mixed :rtype: mixed """...
python
def find(self, id, columns=None): """ Execute a query for a single record by id :param id: The id of the record to retrieve :type id: mixed :param columns: The columns of the record to retrive :type columns: list :return: mixed :rtype: mixed """...
[ "def", "find", "(", "self", ",", "id", ",", "columns", "=", "None", ")", ":", "if", "not", "columns", ":", "columns", "=", "[", "'*'", "]", "return", "self", ".", "where", "(", "'id'", ",", "'='", ",", "id", ")", ".", "first", "(", "1", ",", ...
Execute a query for a single record by id :param id: The id of the record to retrieve :type id: mixed :param columns: The columns of the record to retrive :type columns: list :return: mixed :rtype: mixed
[ "Execute", "a", "query", "for", "a", "single", "record", "by", "id" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/builder.py#L923-L939
sdispater/eloquent
eloquent/query/builder.py
QueryBuilder.first
def first(self, limit=1, columns=None): """ Execute the query and get the first results :param limit: The number of results to get :type limit: int :param columns: The columns to get :type columns: list :return: The result :rtype: mixed """ ...
python
def first(self, limit=1, columns=None): """ Execute the query and get the first results :param limit: The number of results to get :type limit: int :param columns: The columns to get :type columns: list :return: The result :rtype: mixed """ ...
[ "def", "first", "(", "self", ",", "limit", "=", "1", ",", "columns", "=", "None", ")", ":", "if", "not", "columns", ":", "columns", "=", "[", "'*'", "]", "results", "=", "self", ".", "take", "(", "limit", ")", ".", "get", "(", "columns", ")", "...
Execute the query and get the first results :param limit: The number of results to get :type limit: int :param columns: The columns to get :type columns: list :return: The result :rtype: mixed
[ "Execute", "the", "query", "and", "get", "the", "first", "results" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/builder.py#L958-L979
sdispater/eloquent
eloquent/query/builder.py
QueryBuilder.get_fresh
def get_fresh(self, columns=None): """ Execute the query as a fresh "select" statement :param columns: The columns to get :type columns: list :return: The result :rtype: list """ if not columns: columns = ['*'] if not self.columns: ...
python
def get_fresh(self, columns=None): """ Execute the query as a fresh "select" statement :param columns: The columns to get :type columns: list :return: The result :rtype: list """ if not columns: columns = ['*'] if not self.columns: ...
[ "def", "get_fresh", "(", "self", ",", "columns", "=", "None", ")", ":", "if", "not", "columns", ":", "columns", "=", "[", "'*'", "]", "if", "not", "self", ".", "columns", ":", "self", ".", "columns", "=", "columns", "return", "self", ".", "_processor...
Execute the query as a fresh "select" statement :param columns: The columns to get :type columns: list :return: The result :rtype: list
[ "Execute", "the", "query", "as", "a", "fresh", "select", "statement" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/builder.py#L996-L1012
sdispater/eloquent
eloquent/query/builder.py
QueryBuilder._get_list_select
def _get_list_select(self, column, key=None): """ Get the columns that should be used in a list :param column: The column to get the values for :type column: str :param key: The key :type key: str :return: The list of values :rtype: list """ ...
python
def _get_list_select(self, column, key=None): """ Get the columns that should be used in a list :param column: The column to get the values for :type column: str :param key: The key :type key: str :return: The list of values :rtype: list """ ...
[ "def", "_get_list_select", "(", "self", ",", "column", ",", "key", "=", "None", ")", ":", "if", "key", "is", "None", ":", "elements", "=", "[", "column", "]", "else", ":", "elements", "=", "[", "column", ",", "key", "]", "select", "=", "[", "]", ...
Get the columns that should be used in a list :param column: The column to get the values for :type column: str :param key: The key :type key: str :return: The list of values :rtype: list
[ "Get", "the", "columns", "that", "should", "be", "used", "in", "a", "list" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/builder.py#L1071-L1098
sdispater/eloquent
eloquent/query/builder.py
QueryBuilder.increment
def increment(self, column, amount=1, extras=None): """ Increment a column's value by a given amount :param column: The column to increment :type column: str :param amount: The amount by which to increment :type amount: int :param extras: Extra columns ...
python
def increment(self, column, amount=1, extras=None): """ Increment a column's value by a given amount :param column: The column to increment :type column: str :param amount: The amount by which to increment :type amount: int :param extras: Extra columns ...
[ "def", "increment", "(", "self", ",", "column", ",", "amount", "=", "1", ",", "extras", "=", "None", ")", ":", "wrapped", "=", "self", ".", "_grammar", ".", "wrap", "(", "column", ")", "if", "extras", "is", "None", ":", "extras", "=", "{", "}", "...
Increment a column's value by a given amount :param column: The column to increment :type column: str :param amount: The amount by which to increment :type amount: int :param extras: Extra columns :type extras: dict :return: The number of rows affected ...
[ "Increment", "a", "column", "s", "value", "by", "a", "given", "amount" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/builder.py#L1309-L1335
sdispater/eloquent
eloquent/query/builder.py
QueryBuilder.delete
def delete(self, id=None): """ Delete a record from the database :param id: The id of the row to delete :type id: mixed :return: The number of rows deleted :rtype: int """ if id is not None: self.where('id', '=', id) sql = self._gram...
python
def delete(self, id=None): """ Delete a record from the database :param id: The id of the row to delete :type id: mixed :return: The number of rows deleted :rtype: int """ if id is not None: self.where('id', '=', id) sql = self._gram...
[ "def", "delete", "(", "self", ",", "id", "=", "None", ")", ":", "if", "id", "is", "not", "None", ":", "self", ".", "where", "(", "'id'", ",", "'='", ",", "id", ")", "sql", "=", "self", ".", "_grammar", ".", "compile_delete", "(", "self", ")", "...
Delete a record from the database :param id: The id of the row to delete :type id: mixed :return: The number of rows deleted :rtype: int
[ "Delete", "a", "record", "from", "the", "database" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/builder.py#L1365-L1380
sdispater/eloquent
eloquent/query/builder.py
QueryBuilder.merge_wheres
def merge_wheres(self, wheres, bindings): """ Merge a list of where clauses and bindings :param wheres: A list of where clauses :type wheres: list :param bindings: A list of bindings :type bindings: list :rtype: None """ self.wheres = self.where...
python
def merge_wheres(self, wheres, bindings): """ Merge a list of where clauses and bindings :param wheres: A list of where clauses :type wheres: list :param bindings: A list of bindings :type bindings: list :rtype: None """ self.wheres = self.where...
[ "def", "merge_wheres", "(", "self", ",", "wheres", ",", "bindings", ")", ":", "self", ".", "wheres", "=", "self", ".", "wheres", "+", "wheres", "self", ".", "_bindings", "[", "'where'", "]", "=", "self", ".", "_bindings", "[", "'where'", "]", "+", "b...
Merge a list of where clauses and bindings :param wheres: A list of where clauses :type wheres: list :param bindings: A list of bindings :type bindings: list :rtype: None
[ "Merge", "a", "list", "of", "where", "clauses", "and", "bindings" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/builder.py#L1400-L1413
sdispater/eloquent
eloquent/commands/migrations/make_command.py
MigrateMakeCommand.execute
def execute(self, i, o): """ Executes the command. :type i: cleo.inputs.input.Input :type o: cleo.outputs.output.Output """ super(MigrateMakeCommand, self).execute(i, o) creator = MigrationCreator() name = i.get_argument('name') table = i.get_op...
python
def execute(self, i, o): """ Executes the command. :type i: cleo.inputs.input.Input :type o: cleo.outputs.output.Output """ super(MigrateMakeCommand, self).execute(i, o) creator = MigrationCreator() name = i.get_argument('name') table = i.get_op...
[ "def", "execute", "(", "self", ",", "i", ",", "o", ")", ":", "super", "(", "MigrateMakeCommand", ",", "self", ")", ".", "execute", "(", "i", ",", "o", ")", "creator", "=", "MigrationCreator", "(", ")", "name", "=", "i", ".", "get_argument", "(", "'...
Executes the command. :type i: cleo.inputs.input.Input :type o: cleo.outputs.output.Output
[ "Executes", "the", "command", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/commands/migrations/make_command.py#L24-L48
sdispater/eloquent
eloquent/orm/scopes/soft_deleting.py
SoftDeletingScope.remove
def remove(self, builder, model): """ Remove the scope from a given query builder. :param builder: The query builder :type builder: eloquent.orm.builder.Builder :param model: The model :type model: eloquent.orm.Model """ column = model.get_qualified_dele...
python
def remove(self, builder, model): """ Remove the scope from a given query builder. :param builder: The query builder :type builder: eloquent.orm.builder.Builder :param model: The model :type model: eloquent.orm.Model """ column = model.get_qualified_dele...
[ "def", "remove", "(", "self", ",", "builder", ",", "model", ")", ":", "column", "=", "model", ".", "get_qualified_deleted_at_column", "(", ")", "query", "=", "builder", ".", "get_query", "(", ")", "wheres", "=", "[", "]", "for", "where", "in", "query", ...
Remove the scope from a given query builder. :param builder: The query builder :type builder: eloquent.orm.builder.Builder :param model: The model :type model: eloquent.orm.Model
[ "Remove", "the", "scope", "from", "a", "given", "query", "builder", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/scopes/soft_deleting.py#L24-L47
sdispater/eloquent
eloquent/orm/scopes/soft_deleting.py
SoftDeletingScope.extend
def extend(self, builder): """ Extend the query builder with the needed functions. :param builder: The query builder :type builder: eloquent.orm.builder.Builder """ for extension in self._extensions: getattr(self, '_add_%s' % extension)(builder) buil...
python
def extend(self, builder): """ Extend the query builder with the needed functions. :param builder: The query builder :type builder: eloquent.orm.builder.Builder """ for extension in self._extensions: getattr(self, '_add_%s' % extension)(builder) buil...
[ "def", "extend", "(", "self", ",", "builder", ")", ":", "for", "extension", "in", "self", ".", "_extensions", ":", "getattr", "(", "self", ",", "'_add_%s'", "%", "extension", ")", "(", "builder", ")", "builder", ".", "on_delete", "(", "self", ".", "_on...
Extend the query builder with the needed functions. :param builder: The query builder :type builder: eloquent.orm.builder.Builder
[ "Extend", "the", "query", "builder", "with", "the", "needed", "functions", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/scopes/soft_deleting.py#L49-L59
sdispater/eloquent
eloquent/orm/scopes/soft_deleting.py
SoftDeletingScope._only_trashed
def _only_trashed(self, builder): """ The only-trashed extension. :param builder: The query builder :type builder: eloquent.orm.builder.Builder """ model = builder.get_model() self.remove(builder, model) builder.get_query().where_not_null(model.get_qual...
python
def _only_trashed(self, builder): """ The only-trashed extension. :param builder: The query builder :type builder: eloquent.orm.builder.Builder """ model = builder.get_model() self.remove(builder, model) builder.get_query().where_not_null(model.get_qual...
[ "def", "_only_trashed", "(", "self", ",", "builder", ")", ":", "model", "=", "builder", ".", "get_model", "(", ")", "self", ".", "remove", "(", "builder", ",", "model", ")", "builder", ".", "get_query", "(", ")", ".", "where_not_null", "(", "model", "....
The only-trashed extension. :param builder: The query builder :type builder: eloquent.orm.builder.Builder
[ "The", "only", "-", "trashed", "extension", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/scopes/soft_deleting.py#L157-L168
sdispater/eloquent
eloquent/schema/blueprint.py
Blueprint._add_fluent_indexes
def _add_fluent_indexes(self): """ Add the index commands fluently specified on columns: """ for column in self._columns: for index in ['primary', 'unique', 'index']: column_index = column.get(index) if column_index is True: ...
python
def _add_fluent_indexes(self): """ Add the index commands fluently specified on columns: """ for column in self._columns: for index in ['primary', 'unique', 'index']: column_index = column.get(index) if column_index is True: ...
[ "def", "_add_fluent_indexes", "(", "self", ")", ":", "for", "column", "in", "self", ".", "_columns", ":", "for", "index", "in", "[", "'primary'", ",", "'unique'", ",", "'index'", "]", ":", "column_index", "=", "column", ".", "get", "(", "index", ")", "...
Add the index commands fluently specified on columns:
[ "Add", "the", "index", "commands", "fluently", "specified", "on", "columns", ":" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/schema/blueprint.py#L74-L89
sdispater/eloquent
eloquent/schema/blueprint.py
Blueprint.big_integer
def big_integer(self, column, auto_increment=False, unsigned=False): """ Create a new big integer column on the table. :param column: The column :type column: str :type auto_increment: bool :type unsigned: bool :rtype: Fluent """ return self._a...
python
def big_integer(self, column, auto_increment=False, unsigned=False): """ Create a new big integer column on the table. :param column: The column :type column: str :type auto_increment: bool :type unsigned: bool :rtype: Fluent """ return self._a...
[ "def", "big_integer", "(", "self", ",", "column", ",", "auto_increment", "=", "False", ",", "unsigned", "=", "False", ")", ":", "return", "self", ".", "_add_column", "(", "'big_integer'", ",", "column", ",", "auto_increment", "=", "auto_increment", ",", "uns...
Create a new big integer column on the table. :param column: The column :type column: str :type auto_increment: bool :type unsigned: bool :rtype: Fluent
[ "Create", "a", "new", "big", "integer", "column", "on", "the", "table", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/schema/blueprint.py#L376-L391
sdispater/eloquent
eloquent/schema/blueprint.py
Blueprint.medium_integer
def medium_integer(self, column, auto_increment=False, unsigned=False): """ Create a new medium integer column on the table. :param column: The column :type column: str :type auto_increment: bool :type unsigned: bool :rtype: Fluent """ return s...
python
def medium_integer(self, column, auto_increment=False, unsigned=False): """ Create a new medium integer column on the table. :param column: The column :type column: str :type auto_increment: bool :type unsigned: bool :rtype: Fluent """ return s...
[ "def", "medium_integer", "(", "self", ",", "column", ",", "auto_increment", "=", "False", ",", "unsigned", "=", "False", ")", ":", "return", "self", ".", "_add_column", "(", "'medium_integer'", ",", "column", ",", "auto_increment", "=", "auto_increment", ",", ...
Create a new medium integer column on the table. :param column: The column :type column: str :type auto_increment: bool :type unsigned: bool :rtype: Fluent
[ "Create", "a", "new", "medium", "integer", "column", "on", "the", "table", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/schema/blueprint.py#L393-L408
sdispater/eloquent
eloquent/schema/blueprint.py
Blueprint.tiny_integer
def tiny_integer(self, column, auto_increment=False, unsigned=False): """ Create a new tiny integer column on the table. :param column: The column :type column: str :type auto_increment: bool :type unsigned: bool :rtype: Fluent """ return self....
python
def tiny_integer(self, column, auto_increment=False, unsigned=False): """ Create a new tiny integer column on the table. :param column: The column :type column: str :type auto_increment: bool :type unsigned: bool :rtype: Fluent """ return self....
[ "def", "tiny_integer", "(", "self", ",", "column", ",", "auto_increment", "=", "False", ",", "unsigned", "=", "False", ")", ":", "return", "self", ".", "_add_column", "(", "'tiny_integer'", ",", "column", ",", "auto_increment", "=", "auto_increment", ",", "u...
Create a new tiny integer column on the table. :param column: The column :type column: str :type auto_increment: bool :type unsigned: bool :rtype: Fluent
[ "Create", "a", "new", "tiny", "integer", "column", "on", "the", "table", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/schema/blueprint.py#L410-L425
sdispater/eloquent
eloquent/schema/blueprint.py
Blueprint._add_column
def _add_column(self, type, name, **parameters): """ Add a new column to the blueprint. :param type: The column type :type type: str :param name: The column name :type name: str :param parameters: The column parameters :type parameters: dict :r...
python
def _add_column(self, type, name, **parameters): """ Add a new column to the blueprint. :param type: The column type :type type: str :param name: The column name :type name: str :param parameters: The column parameters :type parameters: dict :r...
[ "def", "_add_column", "(", "self", ",", "type", ",", "name", ",", "*", "*", "parameters", ")", ":", "parameters", ".", "update", "(", "{", "'type'", ":", "type", ",", "'name'", ":", "name", "}", ")", "column", "=", "Fluent", "(", "*", "*", "paramet...
Add a new column to the blueprint. :param type: The column type :type type: str :param name: The column name :type name: str :param parameters: The column parameters :type parameters: dict :rtype: Fluent
[ "Add", "a", "new", "column", "to", "the", "blueprint", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/schema/blueprint.py#L698-L721
sdispater/eloquent
eloquent/dbal/platforms/sqlite_platform.py
SQLitePlatform.get_alter_table_sql
def get_alter_table_sql(self, diff): """ Get the ALTER TABLE SQL statement :param diff: The table diff :type diff: eloquent.dbal.table_diff.TableDiff :rtype: list """ #sql = self._get_simple_alter_table_sql(diff) from_table = diff.from_table if ...
python
def get_alter_table_sql(self, diff): """ Get the ALTER TABLE SQL statement :param diff: The table diff :type diff: eloquent.dbal.table_diff.TableDiff :rtype: list """ #sql = self._get_simple_alter_table_sql(diff) from_table = diff.from_table if ...
[ "def", "get_alter_table_sql", "(", "self", ",", "diff", ")", ":", "#sql = self._get_simple_alter_table_sql(diff)", "from_table", "=", "diff", ".", "from_table", "if", "not", "isinstance", "(", "from_table", ",", "Table", ")", ":", "raise", "Exception", "(", "'SQLi...
Get the ALTER TABLE SQL statement :param diff: The table diff :type diff: eloquent.dbal.table_diff.TableDiff :rtype: list
[ "Get", "the", "ALTER", "TABLE", "SQL", "statement" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/dbal/platforms/sqlite_platform.py#L60-L141
sdispater/eloquent
eloquent/dbal/platforms/sqlite_platform.py
SQLitePlatform.get_foreign_keys_in_altered_table
def get_foreign_keys_in_altered_table(self, diff): """ :param diff: The table diff :type diff: eloquent.dbal.table_diff.TableDiff :rtype: list """ foreign_keys = diff.from_table.get_foreign_keys() column_names = self.get_column_names_in_altered_table(diff) ...
python
def get_foreign_keys_in_altered_table(self, diff): """ :param diff: The table diff :type diff: eloquent.dbal.table_diff.TableDiff :rtype: list """ foreign_keys = diff.from_table.get_foreign_keys() column_names = self.get_column_names_in_altered_table(diff) ...
[ "def", "get_foreign_keys_in_altered_table", "(", "self", ",", "diff", ")", ":", "foreign_keys", "=", "diff", ".", "from_table", ".", "get_foreign_keys", "(", ")", "column_names", "=", "self", ".", "get_column_names_in_altered_table", "(", "diff", ")", "for", "key"...
:param diff: The table diff :type diff: eloquent.dbal.table_diff.TableDiff :rtype: list
[ ":", "param", "diff", ":", "The", "table", "diff", ":", "type", "diff", ":", "eloquent", ".", "dbal", ".", "table_diff", ".", "TableDiff" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/dbal/platforms/sqlite_platform.py#L181-L207
sdispater/eloquent
eloquent/orm/relations/belongs_to.py
BelongsTo.get_relation_count_query
def get_relation_count_query(self, query, parent): """ Add the constraints for a relationship count query. :type query: eloquent.orm.Builder :type parent: eloquent.orm.Builder :rtype: Builder """ query.select(QueryExpression('COUNT(*)')) other_key = sel...
python
def get_relation_count_query(self, query, parent): """ Add the constraints for a relationship count query. :type query: eloquent.orm.Builder :type parent: eloquent.orm.Builder :rtype: Builder """ query.select(QueryExpression('COUNT(*)')) other_key = sel...
[ "def", "get_relation_count_query", "(", "self", ",", "query", ",", "parent", ")", ":", "query", ".", "select", "(", "QueryExpression", "(", "'COUNT(*)'", ")", ")", "other_key", "=", "self", ".", "wrap", "(", "'%s.%s'", "%", "(", "query", ".", "get_model", ...
Add the constraints for a relationship count query. :type query: eloquent.orm.Builder :type parent: eloquent.orm.Builder :rtype: Builder
[ "Add", "the", "constraints", "for", "a", "relationship", "count", "query", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/belongs_to.py#L49-L62
sdispater/eloquent
eloquent/orm/relations/belongs_to.py
BelongsTo.match
def match(self, models, results, relation): """ Match the eagerly loaded results to their parents. :type models: list :type results: Collection :type relation: str """ foreign = self._foreign_key other = self._other_key dictionary = {} ...
python
def match(self, models, results, relation): """ Match the eagerly loaded results to their parents. :type models: list :type results: Collection :type relation: str """ foreign = self._foreign_key other = self._other_key dictionary = {} ...
[ "def", "match", "(", "self", ",", "models", ",", "results", ",", "relation", ")", ":", "foreign", "=", "self", ".", "_foreign_key", "other", "=", "self", ".", "_other_key", "dictionary", "=", "{", "}", "for", "result", "in", "results", ":", "dictionary",...
Match the eagerly loaded results to their parents. :type models: list :type results: Collection :type relation: str
[ "Match", "the", "eagerly", "loaded", "results", "to", "their", "parents", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/belongs_to.py#L107-L130
sdispater/eloquent
eloquent/orm/relations/belongs_to.py
BelongsTo.associate
def associate(self, model): """ Associate the model instance to the given parent. :type model: eloquent.Model :rtype: eloquent.Model """ self._parent.set_attribute(self._foreign_key, model.get_attribute(self._other_key)) return self._parent.set_relation(self._r...
python
def associate(self, model): """ Associate the model instance to the given parent. :type model: eloquent.Model :rtype: eloquent.Model """ self._parent.set_attribute(self._foreign_key, model.get_attribute(self._other_key)) return self._parent.set_relation(self._r...
[ "def", "associate", "(", "self", ",", "model", ")", ":", "self", ".", "_parent", ".", "set_attribute", "(", "self", ".", "_foreign_key", ",", "model", ".", "get_attribute", "(", "self", ".", "_other_key", ")", ")", "return", "self", ".", "_parent", ".", ...
Associate the model instance to the given parent. :type model: eloquent.Model :rtype: eloquent.Model
[ "Associate", "the", "model", "instance", "to", "the", "given", "parent", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/belongs_to.py#L132-L142
sdispater/eloquent
eloquent/orm/relations/belongs_to.py
BelongsTo.dissociate
def dissociate(self): """ Dissociate previously associated model from the given parent. :rtype: eloquent.Model """ self._parent.set_attribute(self._foreign_key, None) return self._parent.set_relation(self._relation, None)
python
def dissociate(self): """ Dissociate previously associated model from the given parent. :rtype: eloquent.Model """ self._parent.set_attribute(self._foreign_key, None) return self._parent.set_relation(self._relation, None)
[ "def", "dissociate", "(", "self", ")", ":", "self", ".", "_parent", ".", "set_attribute", "(", "self", ".", "_foreign_key", ",", "None", ")", "return", "self", ".", "_parent", ".", "set_relation", "(", "self", ".", "_relation", ",", "None", ")" ]
Dissociate previously associated model from the given parent. :rtype: eloquent.Model
[ "Dissociate", "previously", "associated", "model", "from", "the", "given", "parent", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/belongs_to.py#L144-L152
sdispater/eloquent
eloquent/commands/migrations/status_command.py
StatusCommand.execute
def execute(self, i, o): """ Executes the command. :type i: cleo.inputs.input.Input :type o: cleo.outputs.output.Output """ super(StatusCommand, self).execute(i, o) database = i.get_option('database') repository = DatabaseMigrationRepository(self._resolv...
python
def execute(self, i, o): """ Executes the command. :type i: cleo.inputs.input.Input :type o: cleo.outputs.output.Output """ super(StatusCommand, self).execute(i, o) database = i.get_option('database') repository = DatabaseMigrationRepository(self._resolv...
[ "def", "execute", "(", "self", ",", "i", ",", "o", ")", ":", "super", "(", "StatusCommand", ",", "self", ")", ".", "execute", "(", "i", ",", "o", ")", "database", "=", "i", ".", "get_option", "(", "'database'", ")", "repository", "=", "DatabaseMigrat...
Executes the command. :type i: cleo.inputs.input.Input :type o: cleo.outputs.output.Output
[ "Executes", "the", "command", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/commands/migrations/status_command.py#L20-L62
sdispater/eloquent
eloquent/schema/grammars/sqlite_grammar.py
SQLiteSchemaGrammar.compile_rename_column
def compile_rename_column(self, blueprint, command, connection): """ Compile a rename column command. :param blueprint: The blueprint :type blueprint: Blueprint :param command: The command :type command: Fluent :param connection: The connection :type co...
python
def compile_rename_column(self, blueprint, command, connection): """ Compile a rename column command. :param blueprint: The blueprint :type blueprint: Blueprint :param command: The command :type command: Fluent :param connection: The connection :type co...
[ "def", "compile_rename_column", "(", "self", ",", "blueprint", ",", "command", ",", "connection", ")", ":", "# The code is a little complex. It will propably change", "# if we support complete diffs in dbal", "sql", "=", "[", "]", "schema", "=", "connection", ".", "get_sc...
Compile a rename column command. :param blueprint: The blueprint :type blueprint: Blueprint :param command: The command :type command: Fluent :param connection: The connection :type connection: eloquent.connections.Connection :rtype: list
[ "Compile", "a", "rename", "column", "command", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/schema/grammars/sqlite_grammar.py#L15-L156
sdispater/eloquent
eloquent/schema/grammars/sqlite_grammar.py
SQLiteSchemaGrammar.compile_change
def compile_change(self, blueprint, command, connection): """ Compile a change column command into a series of SQL statement. :param blueprint: The blueprint :type blueprint: eloquent.schema.Blueprint :param command: The command :type command: Fluent :param con...
python
def compile_change(self, blueprint, command, connection): """ Compile a change column command into a series of SQL statement. :param blueprint: The blueprint :type blueprint: eloquent.schema.Blueprint :param command: The command :type command: Fluent :param con...
[ "def", "compile_change", "(", "self", ",", "blueprint", ",", "command", ",", "connection", ")", ":", "sql", "=", "[", "]", "schema", "=", "connection", ".", "get_schema_manager", "(", ")", "table", "=", "self", ".", "get_table_prefix", "(", ")", "+", "bl...
Compile a change column command into a series of SQL statement. :param blueprint: The blueprint :type blueprint: eloquent.schema.Blueprint :param command: The command :type command: Fluent :param connection: The connection :type connection: eloquent.connections.Connect...
[ "Compile", "a", "change", "column", "command", "into", "a", "series", "of", "SQL", "statement", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/schema/grammars/sqlite_grammar.py#L158-L249
sdispater/eloquent
eloquent/schema/grammars/sqlite_grammar.py
SQLiteSchemaGrammar.compile_create
def compile_create(self, blueprint, command, _): """ Compile a create table command. """ columns = ', '.join(self._get_columns(blueprint)) sql = 'CREATE TABLE %s (%s' % (self.wrap_table(blueprint), columns) sql += self._add_foreign_keys(blueprint) sql += self._...
python
def compile_create(self, blueprint, command, _): """ Compile a create table command. """ columns = ', '.join(self._get_columns(blueprint)) sql = 'CREATE TABLE %s (%s' % (self.wrap_table(blueprint), columns) sql += self._add_foreign_keys(blueprint) sql += self._...
[ "def", "compile_create", "(", "self", ",", "blueprint", ",", "command", ",", "_", ")", ":", "columns", "=", "', '", ".", "join", "(", "self", ".", "_get_columns", "(", "blueprint", ")", ")", "sql", "=", "'CREATE TABLE %s (%s'", "%", "(", "self", ".", "...
Compile a create table command.
[ "Compile", "a", "create", "table", "command", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/schema/grammars/sqlite_grammar.py#L265-L277
sdispater/eloquent
eloquent/orm/relations/has_one_or_many.py
HasOneOrMany.match_one
def match_one(self, models, results, relation): """ Match the eargerly loaded resuls to their single parents. :param models: The parents :type models: list :param results: The results collection :type results: Collection :param relation: The relation :t...
python
def match_one(self, models, results, relation): """ Match the eargerly loaded resuls to their single parents. :param models: The parents :type models: list :param results: The results collection :type results: Collection :param relation: The relation :t...
[ "def", "match_one", "(", "self", ",", "models", ",", "results", ",", "relation", ")", ":", "return", "self", ".", "_match_one_or_many", "(", "models", ",", "results", ",", "relation", ",", "'one'", ")" ]
Match the eargerly loaded resuls to their single parents. :param models: The parents :type models: list :param results: The results collection :type results: Collection :param relation: The relation :type relation: str :rtype: list
[ "Match", "the", "eargerly", "loaded", "resuls", "to", "their", "single", "parents", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/has_one_or_many.py#L42-L57
sdispater/eloquent
eloquent/orm/relations/has_one_or_many.py
HasOneOrMany.match_many
def match_many(self, models, results, relation): """ Match the eargerly loaded resuls to their single parents. :param models: The parents :type models: list :param results: The results collection :type results: Collection :param relation: The relation :...
python
def match_many(self, models, results, relation): """ Match the eargerly loaded resuls to their single parents. :param models: The parents :type models: list :param results: The results collection :type results: Collection :param relation: The relation :...
[ "def", "match_many", "(", "self", ",", "models", ",", "results", ",", "relation", ")", ":", "return", "self", ".", "_match_one_or_many", "(", "models", ",", "results", ",", "relation", ",", "'many'", ")" ]
Match the eargerly loaded resuls to their single parents. :param models: The parents :type models: list :param results: The results collection :type results: Collection :param relation: The relation :type relation: str :rtype: list
[ "Match", "the", "eargerly", "loaded", "resuls", "to", "their", "single", "parents", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/has_one_or_many.py#L59-L74
sdispater/eloquent
eloquent/orm/relations/has_one_or_many.py
HasOneOrMany._match_one_or_many
def _match_one_or_many(self, models, results, relation, type): """ Match the eargerly loaded resuls to their single parents. :param models: The parents :type models: list :param results: The results collection :type results: Collection :param relation: The rela...
python
def _match_one_or_many(self, models, results, relation, type): """ Match the eargerly loaded resuls to their single parents. :param models: The parents :type models: list :param results: The results collection :type results: Collection :param relation: The rela...
[ "def", "_match_one_or_many", "(", "self", ",", "models", ",", "results", ",", "relation", ",", "type", ")", ":", "dictionary", "=", "self", ".", "_build_dictionary", "(", "results", ")", "for", "model", "in", "models", ":", "key", "=", "model", ".", "get...
Match the eargerly loaded resuls to their single parents. :param models: The parents :type models: list :param results: The results collection :type results: Collection :param relation: The relation :type relation: str :param type: The match type :type...
[ "Match", "the", "eargerly", "loaded", "resuls", "to", "their", "single", "parents", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/has_one_or_many.py#L76-L104
sdispater/eloquent
eloquent/orm/relations/has_one_or_many.py
HasOneOrMany._get_relation_value
def _get_relation_value(self, dictionary, key, type): """ Get the value of the relationship by one or many type. :type dictionary: dict :type key: str :type type: str """ value = dictionary[key] if type == 'one': return value[0] retu...
python
def _get_relation_value(self, dictionary, key, type): """ Get the value of the relationship by one or many type. :type dictionary: dict :type key: str :type type: str """ value = dictionary[key] if type == 'one': return value[0] retu...
[ "def", "_get_relation_value", "(", "self", ",", "dictionary", ",", "key", ",", "type", ")", ":", "value", "=", "dictionary", "[", "key", "]", "if", "type", "==", "'one'", ":", "return", "value", "[", "0", "]", "return", "self", ".", "_related", ".", ...
Get the value of the relationship by one or many type. :type dictionary: dict :type key: str :type type: str
[ "Get", "the", "value", "of", "the", "relationship", "by", "one", "or", "many", "type", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/has_one_or_many.py#L106-L119
sdispater/eloquent
eloquent/orm/relations/has_one_or_many.py
HasOneOrMany.first_or_new
def first_or_new(self, _attributes=None, **attributes): """ Get the first related model record matching the attributes or instantiate it. :param attributes: The attributes :type attributes: dict :rtype: Model """ if _attributes is not None: attribut...
python
def first_or_new(self, _attributes=None, **attributes): """ Get the first related model record matching the attributes or instantiate it. :param attributes: The attributes :type attributes: dict :rtype: Model """ if _attributes is not None: attribut...
[ "def", "first_or_new", "(", "self", ",", "_attributes", "=", "None", ",", "*", "*", "attributes", ")", ":", "if", "_attributes", "is", "not", "None", ":", "attributes", ".", "update", "(", "_attributes", ")", "instance", "=", "self", ".", "where", "(", ...
Get the first related model record matching the attributes or instantiate it. :param attributes: The attributes :type attributes: dict :rtype: Model
[ "Get", "the", "first", "related", "model", "record", "matching", "the", "attributes", "or", "instantiate", "it", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/has_one_or_many.py#L193-L211
sdispater/eloquent
eloquent/orm/relations/has_one_or_many.py
HasOneOrMany.first_or_create
def first_or_create(self, _attributes=None, **attributes): """ Get the first related record matching the attributes or create it. :param attributes: The attributes :type attributes: dict :rtype: Model """ if _attributes is not None: attributes.updat...
python
def first_or_create(self, _attributes=None, **attributes): """ Get the first related record matching the attributes or create it. :param attributes: The attributes :type attributes: dict :rtype: Model """ if _attributes is not None: attributes.updat...
[ "def", "first_or_create", "(", "self", ",", "_attributes", "=", "None", ",", "*", "*", "attributes", ")", ":", "if", "_attributes", "is", "not", "None", ":", "attributes", ".", "update", "(", "_attributes", ")", "instance", "=", "self", ".", "where", "("...
Get the first related record matching the attributes or create it. :param attributes: The attributes :type attributes: dict :rtype: Model
[ "Get", "the", "first", "related", "record", "matching", "the", "attributes", "or", "create", "it", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/has_one_or_many.py#L213-L230
sdispater/eloquent
eloquent/commands/migrations/reset_command.py
ResetCommand.execute
def execute(self, i, o): """ Executes the command. :type i: cleo.inputs.input.Input :type o: cleo.outputs.output.Output """ super(ResetCommand, self).execute(i, o) dialog = self.get_helper('dialog') confirm = dialog.ask_confirmation( o, ...
python
def execute(self, i, o): """ Executes the command. :type i: cleo.inputs.input.Input :type o: cleo.outputs.output.Output """ super(ResetCommand, self).execute(i, o) dialog = self.get_helper('dialog') confirm = dialog.ask_confirmation( o, ...
[ "def", "execute", "(", "self", ",", "i", ",", "o", ")", ":", "super", "(", "ResetCommand", ",", "self", ")", ".", "execute", "(", "i", ",", "o", ")", "dialog", "=", "self", ".", "get_helper", "(", "'dialog'", ")", "confirm", "=", "dialog", ".", "...
Executes the command. :type i: cleo.inputs.input.Input :type o: cleo.outputs.output.Output
[ "Executes", "the", "command", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/commands/migrations/reset_command.py#L23-L62
sdispater/eloquent
eloquent/orm/relations/morph_to_many.py
MorphToMany.get_relation_count_query
def get_relation_count_query(self, query, parent): """ Add the constraints for a relationship count query. :type query: eloquent.orm.Builder :type parent: eloquent.orm.Builder :rtype: eloquent.orm.Builder """ query = super(MorphToMany, self).get_relation_count_q...
python
def get_relation_count_query(self, query, parent): """ Add the constraints for a relationship count query. :type query: eloquent.orm.Builder :type parent: eloquent.orm.Builder :rtype: eloquent.orm.Builder """ query = super(MorphToMany, self).get_relation_count_q...
[ "def", "get_relation_count_query", "(", "self", ",", "query", ",", "parent", ")", ":", "query", "=", "super", "(", "MorphToMany", ",", "self", ")", ".", "get_relation_count_query", "(", "query", ",", "parent", ")", "return", "query", ".", "where", "(", "'%...
Add the constraints for a relationship count query. :type query: eloquent.orm.Builder :type parent: eloquent.orm.Builder :rtype: eloquent.orm.Builder
[ "Add", "the", "constraints", "for", "a", "relationship", "count", "query", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/morph_to_many.py#L48-L59
sdispater/eloquent
eloquent/orm/relations/morph_to_many.py
MorphToMany.add_eager_constraints
def add_eager_constraints(self, models): """ Set the constraints for an eager load of the relation. :type models: list """ super(MorphToMany, self).add_eager_constraints(models) self._query.where('%s.%s' % (self._table, self._morph_type), self._morph_class)
python
def add_eager_constraints(self, models): """ Set the constraints for an eager load of the relation. :type models: list """ super(MorphToMany, self).add_eager_constraints(models) self._query.where('%s.%s' % (self._table, self._morph_type), self._morph_class)
[ "def", "add_eager_constraints", "(", "self", ",", "models", ")", ":", "super", "(", "MorphToMany", ",", "self", ")", ".", "add_eager_constraints", "(", "models", ")", "self", ".", "_query", ".", "where", "(", "'%s.%s'", "%", "(", "self", ".", "_table", "...
Set the constraints for an eager load of the relation. :type models: list
[ "Set", "the", "constraints", "for", "an", "eager", "load", "of", "the", "relation", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/morph_to_many.py#L61-L69
sdispater/eloquent
eloquent/orm/relations/morph_to_many.py
MorphToMany._create_attach_record
def _create_attach_record(self, id, timed): """ Create a new pivot attachement record. """ record = super(MorphToMany, self)._create_attach_record(id, timed) record[self._morph_type] = self._morph_class return record
python
def _create_attach_record(self, id, timed): """ Create a new pivot attachement record. """ record = super(MorphToMany, self)._create_attach_record(id, timed) record[self._morph_type] = self._morph_class return record
[ "def", "_create_attach_record", "(", "self", ",", "id", ",", "timed", ")", ":", "record", "=", "super", "(", "MorphToMany", ",", "self", ")", ".", "_create_attach_record", "(", "id", ",", "timed", ")", "record", "[", "self", ".", "_morph_type", "]", "=",...
Create a new pivot attachement record.
[ "Create", "a", "new", "pivot", "attachement", "record", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/morph_to_many.py#L71-L79
sdispater/eloquent
eloquent/orm/relations/morph_to_many.py
MorphToMany._new_pivot_query
def _new_pivot_query(self): """ Create a new query builder for the pivot table. :rtype: eloquent.orm.Builder """ query = super(MorphToMany, self)._new_pivot_query() return query.where(self._morph_type, self._morph_class)
python
def _new_pivot_query(self): """ Create a new query builder for the pivot table. :rtype: eloquent.orm.Builder """ query = super(MorphToMany, self)._new_pivot_query() return query.where(self._morph_type, self._morph_class)
[ "def", "_new_pivot_query", "(", "self", ")", ":", "query", "=", "super", "(", "MorphToMany", ",", "self", ")", ".", "_new_pivot_query", "(", ")", "return", "query", ".", "where", "(", "self", ".", "_morph_type", ",", "self", ".", "_morph_class", ")" ]
Create a new query builder for the pivot table. :rtype: eloquent.orm.Builder
[ "Create", "a", "new", "query", "builder", "for", "the", "pivot", "table", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/morph_to_many.py#L81-L89
sdispater/eloquent
eloquent/orm/relations/morph_to_many.py
MorphToMany.new_pivot
def new_pivot(self, attributes=None, exists=False): """ Create a new pivot model instance. """ from .morph_pivot import MorphPivot pivot = MorphPivot(self._parent, attributes, self._table, exists) pivot.set_pivot_keys(self._foreign_key, self._other_key)\ .se...
python
def new_pivot(self, attributes=None, exists=False): """ Create a new pivot model instance. """ from .morph_pivot import MorphPivot pivot = MorphPivot(self._parent, attributes, self._table, exists) pivot.set_pivot_keys(self._foreign_key, self._other_key)\ .se...
[ "def", "new_pivot", "(", "self", ",", "attributes", "=", "None", ",", "exists", "=", "False", ")", ":", "from", ".", "morph_pivot", "import", "MorphPivot", "pivot", "=", "MorphPivot", "(", "self", ".", "_parent", ",", "attributes", ",", "self", ".", "_ta...
Create a new pivot model instance.
[ "Create", "a", "new", "pivot", "model", "instance", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/morph_to_many.py#L91-L103
sdispater/eloquent
eloquent/commands/migrations/install_command.py
InstallCommand.execute
def execute(self, i, o): """ Executes the command. :type i: cleo.inputs.input.Input :type o: cleo.outputs.output.Output """ super(InstallCommand, self).execute(i, o) database = i.get_option('database') repository = DatabaseMigrationRepository(self._resol...
python
def execute(self, i, o): """ Executes the command. :type i: cleo.inputs.input.Input :type o: cleo.outputs.output.Output """ super(InstallCommand, self).execute(i, o) database = i.get_option('database') repository = DatabaseMigrationRepository(self._resol...
[ "def", "execute", "(", "self", ",", "i", ",", "o", ")", ":", "super", "(", "InstallCommand", ",", "self", ")", ".", "execute", "(", "i", ",", "o", ")", "database", "=", "i", ".", "get_option", "(", "'database'", ")", "repository", "=", "DatabaseMigra...
Executes the command. :type i: cleo.inputs.input.Input :type o: cleo.outputs.output.Output
[ "Executes", "the", "command", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/commands/migrations/install_command.py#L18-L33
sdispater/eloquent
eloquent/query/processors/mysql_processor.py
MySqlQueryProcessor.process_insert_get_id
def process_insert_get_id(self, query, sql, values, sequence=None): """ Process an "insert get ID" query. :param query: A QueryBuilder instance :type query: QueryBuilder :param sql: The sql query to execute :type sql: str :param values: The value bindings ...
python
def process_insert_get_id(self, query, sql, values, sequence=None): """ Process an "insert get ID" query. :param query: A QueryBuilder instance :type query: QueryBuilder :param sql: The sql query to execute :type sql: str :param values: The value bindings ...
[ "def", "process_insert_get_id", "(", "self", ",", "query", ",", "sql", ",", "values", ",", "sequence", "=", "None", ")", ":", "if", "not", "query", ".", "get_connection", "(", ")", ".", "transaction_level", "(", ")", ":", "with", "query", ".", "get_conne...
Process an "insert get ID" query. :param query: A QueryBuilder instance :type query: QueryBuilder :param sql: The sql query to execute :type sql: str :param values: The value bindings :type values: list :param sequence: The ids sequence :type sequence:...
[ "Process", "an", "insert", "get", "ID", "query", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/processors/mysql_processor.py#L8-L51
sdispater/eloquent
eloquent/orm/builder.py
Builder.chunk
def chunk(self, count): """ Chunk the results of the query :param count: The chunk size :type count: int :return: The current chunk :rtype: list """ page = 1 results = self.for_page(page, count).get() while results: yield res...
python
def chunk(self, count): """ Chunk the results of the query :param count: The chunk size :type count: int :return: The current chunk :rtype: list """ page = 1 results = self.for_page(page, count).get() while results: yield res...
[ "def", "chunk", "(", "self", ",", "count", ")", ":", "page", "=", "1", "results", "=", "self", ".", "for_page", "(", "page", ",", "count", ")", ".", "get", "(", ")", "while", "results", ":", "yield", "results", "page", "+=", "1", "results", "=", ...
Chunk the results of the query :param count: The chunk size :type count: int :return: The current chunk :rtype: list
[ "Chunk", "the", "results", "of", "the", "query" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L167-L185
sdispater/eloquent
eloquent/orm/builder.py
Builder.lists
def lists(self, column, key=None): """ Get a list with the values of a given column :param column: The column to get the values for :type column: str :param key: The key :type key: str :return: The list of values :rtype: list or dict """ ...
python
def lists(self, column, key=None): """ Get a list with the values of a given column :param column: The column to get the values for :type column: str :param key: The key :type key: str :return: The list of values :rtype: list or dict """ ...
[ "def", "lists", "(", "self", ",", "column", ",", "key", "=", "None", ")", ":", "results", "=", "self", ".", "_query", ".", "lists", "(", "column", ",", "key", ")", "if", "self", ".", "_model", ".", "has_get_mutator", "(", "column", ")", ":", "if", ...
Get a list with the values of a given column :param column: The column to get the values for :type column: str :param key: The key :type key: str :return: The list of values :rtype: list or dict
[ "Get", "a", "list", "with", "the", "values", "of", "a", "given", "column" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L187-L214
sdispater/eloquent
eloquent/orm/builder.py
Builder.increment
def increment(self, column, amount=1, extras=None): """ Increment a column's value by a given amount :param column: The column to increment :type column: str :param amount: The amount by which to increment :type amount: int :param extras: Extra columns ...
python
def increment(self, column, amount=1, extras=None): """ Increment a column's value by a given amount :param column: The column to increment :type column: str :param amount: The amount by which to increment :type amount: int :param extras: Extra columns ...
[ "def", "increment", "(", "self", ",", "column", ",", "amount", "=", "1", ",", "extras", "=", "None", ")", ":", "extras", "=", "self", ".", "_add_updated_at_column", "(", "extras", ")", "return", "self", ".", "_query", ".", "increment", "(", "column", "...
Increment a column's value by a given amount :param column: The column to increment :type column: str :param amount: The amount by which to increment :type amount: int :param extras: Extra columns :type extras: dict :return: The number of rows affected ...
[ "Increment", "a", "column", "s", "value", "by", "a", "given", "amount" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L259-L277
sdispater/eloquent
eloquent/orm/builder.py
Builder.decrement
def decrement(self, column, amount=1, extras=None): """ Decrement a column's value by a given amount :param column: The column to increment :type column: str :param amount: The amount by which to increment :type amount: int :param extras: Extra columns ...
python
def decrement(self, column, amount=1, extras=None): """ Decrement a column's value by a given amount :param column: The column to increment :type column: str :param amount: The amount by which to increment :type amount: int :param extras: Extra columns ...
[ "def", "decrement", "(", "self", ",", "column", ",", "amount", "=", "1", ",", "extras", "=", "None", ")", ":", "extras", "=", "self", ".", "_add_updated_at_column", "(", "extras", ")", "return", "self", ".", "_query", ".", "decrement", "(", "column", "...
Decrement a column's value by a given amount :param column: The column to increment :type column: str :param amount: The amount by which to increment :type amount: int :param extras: Extra columns :type extras: dict :return: The number of rows affected ...
[ "Decrement", "a", "column", "s", "value", "by", "a", "given", "amount" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L279-L297
sdispater/eloquent
eloquent/orm/builder.py
Builder.get_models
def get_models(self, columns=None): """ Get the hydrated models without eager loading. :param columns: The columns to get :type columns: list :return: A list of models :rtype: list """ results = self._query.get(columns) connection = self._model....
python
def get_models(self, columns=None): """ Get the hydrated models without eager loading. :param columns: The columns to get :type columns: list :return: A list of models :rtype: list """ results = self._query.get(columns) connection = self._model....
[ "def", "get_models", "(", "self", ",", "columns", "=", "None", ")", ":", "results", "=", "self", ".", "_query", ".", "get", "(", "columns", ")", "connection", "=", "self", ".", "_model", ".", "get_connection_name", "(", ")", "return", "self", ".", "_mo...
Get the hydrated models without eager loading. :param columns: The columns to get :type columns: list :return: A list of models :rtype: list
[ "Get", "the", "hydrated", "models", "without", "eager", "loading", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L342-L356
sdispater/eloquent
eloquent/orm/builder.py
Builder.eager_load_relations
def eager_load_relations(self, models): """ Eager load the relationship of the models. :param models: :type models: list :return: The models :rtype: list """ for name, constraints in self._eager_load.items(): if name.find('.') == -1: ...
python
def eager_load_relations(self, models): """ Eager load the relationship of the models. :param models: :type models: list :return: The models :rtype: list """ for name, constraints in self._eager_load.items(): if name.find('.') == -1: ...
[ "def", "eager_load_relations", "(", "self", ",", "models", ")", ":", "for", "name", ",", "constraints", "in", "self", ".", "_eager_load", ".", "items", "(", ")", ":", "if", "name", ".", "find", "(", "'.'", ")", "==", "-", "1", ":", "models", "=", "...
Eager load the relationship of the models. :param models: :type models: list :return: The models :rtype: list
[ "Eager", "load", "the", "relationship", "of", "the", "models", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L358-L372
sdispater/eloquent
eloquent/orm/builder.py
Builder._load_relation
def _load_relation(self, models, name, constraints): """ Eagerly load the relationship on a set of models. :rtype: list """ relation = self.get_relation(name) relation.add_eager_constraints(models) if callable(constraints): constraints(relation) ...
python
def _load_relation(self, models, name, constraints): """ Eagerly load the relationship on a set of models. :rtype: list """ relation = self.get_relation(name) relation.add_eager_constraints(models) if callable(constraints): constraints(relation) ...
[ "def", "_load_relation", "(", "self", ",", "models", ",", "name", ",", "constraints", ")", ":", "relation", "=", "self", ".", "get_relation", "(", "name", ")", "relation", ".", "add_eager_constraints", "(", "models", ")", "if", "callable", "(", "constraints"...
Eagerly load the relationship on a set of models. :rtype: list
[ "Eagerly", "load", "the", "relationship", "on", "a", "set", "of", "models", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L374-L393
sdispater/eloquent
eloquent/orm/builder.py
Builder._has_nested
def _has_nested(self, relations, operator='>=', count=1, boolean='and', extra=None): """ Add nested relationship count conditions to the query. :param relations: nested relations :type relations: str :param operator: The operator :type operator: str :param coun...
python
def _has_nested(self, relations, operator='>=', count=1, boolean='and', extra=None): """ Add nested relationship count conditions to the query. :param relations: nested relations :type relations: str :param operator: The operator :type operator: str :param coun...
[ "def", "_has_nested", "(", "self", ",", "relations", ",", "operator", "=", "'>='", ",", "count", "=", "1", ",", "boolean", "=", "'and'", ",", "extra", "=", "None", ")", ":", "relations", "=", "relations", ".", "split", "(", "'.'", ")", "def", "closur...
Add nested relationship count conditions to the query. :param relations: nested relations :type relations: str :param operator: The operator :type operator: str :param count: The count :type count: int :param boolean: The boolean value :type boolean: s...
[ "Add", "nested", "relationship", "count", "conditions", "to", "the", "query", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L518-L547
sdispater/eloquent
eloquent/orm/builder.py
Builder.doesnt_have
def doesnt_have(self, relation, boolean='and', extra=None): """ Add a relationship count to the query. :param relation: The relation to count :type relation: str :param boolean: The boolean value :type boolean: str :param extra: The extra query :type ex...
python
def doesnt_have(self, relation, boolean='and', extra=None): """ Add a relationship count to the query. :param relation: The relation to count :type relation: str :param boolean: The boolean value :type boolean: str :param extra: The extra query :type ex...
[ "def", "doesnt_have", "(", "self", ",", "relation", ",", "boolean", "=", "'and'", ",", "extra", "=", "None", ")", ":", "return", "self", ".", "has", "(", "relation", ",", "'<'", ",", "1", ",", "boolean", ",", "extra", ")" ]
Add a relationship count to the query. :param relation: The relation to count :type relation: str :param boolean: The boolean value :type boolean: str :param extra: The extra query :type extra: Builder or callable :rtype: Builder
[ "Add", "a", "relationship", "count", "to", "the", "query", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L549-L564
sdispater/eloquent
eloquent/orm/builder.py
Builder.where_has
def where_has(self, relation, extra, operator='>=', count=1): """ Add a relationship count condition to the query with where clauses. :param relation: The relation to count :type relation: str :param extra: The extra query :type extra: Builder or callable :para...
python
def where_has(self, relation, extra, operator='>=', count=1): """ Add a relationship count condition to the query with where clauses. :param relation: The relation to count :type relation: str :param extra: The extra query :type extra: Builder or callable :para...
[ "def", "where_has", "(", "self", ",", "relation", ",", "extra", ",", "operator", "=", "'>='", ",", "count", "=", "1", ")", ":", "return", "self", ".", "has", "(", "relation", ",", "operator", ",", "count", ",", "'and'", ",", "extra", ")" ]
Add a relationship count condition to the query with where clauses. :param relation: The relation to count :type relation: str :param extra: The extra query :type extra: Builder or callable :param operator: The operator :type operator: str :param count: The co...
[ "Add", "a", "relationship", "count", "condition", "to", "the", "query", "with", "where", "clauses", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L566-L584
sdispater/eloquent
eloquent/orm/builder.py
Builder.or_has
def or_has(self, relation, operator='>=', count=1): """ Add a relationship count condition to the query with an "or". :param relation: The relation to count :type relation: str :param operator: The operator :type operator: str :param count: The count :t...
python
def or_has(self, relation, operator='>=', count=1): """ Add a relationship count condition to the query with an "or". :param relation: The relation to count :type relation: str :param operator: The operator :type operator: str :param count: The count :t...
[ "def", "or_has", "(", "self", ",", "relation", ",", "operator", "=", "'>='", ",", "count", "=", "1", ")", ":", "return", "self", ".", "has", "(", "relation", ",", "operator", ",", "count", ",", "'or'", ")" ]
Add a relationship count condition to the query with an "or". :param relation: The relation to count :type relation: str :param operator: The operator :type operator: str :param count: The count :type count: int :rtype: Builder
[ "Add", "a", "relationship", "count", "condition", "to", "the", "query", "with", "an", "or", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L600-L615
sdispater/eloquent
eloquent/orm/builder.py
Builder.or_where_has
def or_where_has(self, relation, extra, operator='>=', count=1): """ Add a relationship count condition to the query with where clauses and an "or". :param relation: The relation to count :type relation: str :param extra: The extra query :type extra: Builder or callable...
python
def or_where_has(self, relation, extra, operator='>=', count=1): """ Add a relationship count condition to the query with where clauses and an "or". :param relation: The relation to count :type relation: str :param extra: The extra query :type extra: Builder or callable...
[ "def", "or_where_has", "(", "self", ",", "relation", ",", "extra", ",", "operator", "=", "'>='", ",", "count", "=", "1", ")", ":", "return", "self", ".", "has", "(", "relation", ",", "operator", ",", "count", ",", "'or'", ",", "extra", ")" ]
Add a relationship count condition to the query with where clauses and an "or". :param relation: The relation to count :type relation: str :param extra: The extra query :type extra: Builder or callable :param operator: The operator :type operator: str :param c...
[ "Add", "a", "relationship", "count", "condition", "to", "the", "query", "with", "where", "clauses", "and", "an", "or", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L617-L635
sdispater/eloquent
eloquent/orm/builder.py
Builder._merge_wheres_to_has
def _merge_wheres_to_has(self, has_query, relation): """ Merge the "wheres" from the relation query to a has query. :param has_query: The has query :type has_query: Builder :param relation: The relation to count :type relation: eloquent.orm.relations.Relation ""...
python
def _merge_wheres_to_has(self, has_query, relation): """ Merge the "wheres" from the relation query to a has query. :param has_query: The has query :type has_query: Builder :param relation: The relation to count :type relation: eloquent.orm.relations.Relation ""...
[ "def", "_merge_wheres_to_has", "(", "self", ",", "has_query", ",", "relation", ")", ":", "relation_query", "=", "relation", ".", "get_base_query", "(", ")", "has_query", ".", "merge_wheres", "(", "relation_query", ".", "wheres", ",", "relation_query", ".", "get_...
Merge the "wheres" from the relation query to a has query. :param has_query: The has query :type has_query: Builder :param relation: The relation to count :type relation: eloquent.orm.relations.Relation
[ "Merge", "the", "wheres", "from", "the", "relation", "query", "to", "a", "has", "query", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L665-L679
sdispater/eloquent
eloquent/orm/builder.py
Builder._get_has_relation_query
def _get_has_relation_query(self, relation): """ Get the "has" relation base query :type relation: str :rtype: Builder """ from .relations import Relation return Relation.no_constraints( lambda: getattr(self.get_model(), relation)() )
python
def _get_has_relation_query(self, relation): """ Get the "has" relation base query :type relation: str :rtype: Builder """ from .relations import Relation return Relation.no_constraints( lambda: getattr(self.get_model(), relation)() )
[ "def", "_get_has_relation_query", "(", "self", ",", "relation", ")", ":", "from", ".", "relations", "import", "Relation", "return", "Relation", ".", "no_constraints", "(", "lambda", ":", "getattr", "(", "self", ".", "get_model", "(", ")", ",", "relation", ")...
Get the "has" relation base query :type relation: str :rtype: Builder
[ "Get", "the", "has", "relation", "base", "query" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L681-L693
sdispater/eloquent
eloquent/orm/builder.py
Builder.with_
def with_(self, *relations): """ Set the relationships that should be eager loaded. :return: The current Builder instance :rtype: Builder """ if not relations: return self eagers = self._parse_relations(list(relations)) self._eager_load.upda...
python
def with_(self, *relations): """ Set the relationships that should be eager loaded. :return: The current Builder instance :rtype: Builder """ if not relations: return self eagers = self._parse_relations(list(relations)) self._eager_load.upda...
[ "def", "with_", "(", "self", ",", "*", "relations", ")", ":", "if", "not", "relations", ":", "return", "self", "eagers", "=", "self", ".", "_parse_relations", "(", "list", "(", "relations", ")", ")", "self", ".", "_eager_load", ".", "update", "(", "eag...
Set the relationships that should be eager loaded. :return: The current Builder instance :rtype: Builder
[ "Set", "the", "relationships", "that", "should", "be", "eager", "loaded", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L695-L709
sdispater/eloquent
eloquent/orm/builder.py
Builder._parse_relations
def _parse_relations(self, relations): """ Parse a list of relations into individuals. :param relations: The relation to parse :type relations: list :rtype: dict """ results = {} for relation in relations: if isinstance(relation, dict): ...
python
def _parse_relations(self, relations): """ Parse a list of relations into individuals. :param relations: The relation to parse :type relations: list :rtype: dict """ results = {} for relation in relations: if isinstance(relation, dict): ...
[ "def", "_parse_relations", "(", "self", ",", "relations", ")", ":", "results", "=", "{", "}", "for", "relation", "in", "relations", ":", "if", "isinstance", "(", "relation", ",", "dict", ")", ":", "name", "=", "list", "(", "relation", ".", "keys", "(",...
Parse a list of relations into individuals. :param relations: The relation to parse :type relations: list :rtype: dict
[ "Parse", "a", "list", "of", "relations", "into", "individuals", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L711-L734
sdispater/eloquent
eloquent/orm/builder.py
Builder._parse_nested
def _parse_nested(self, name, results): """ Parse the nested relationship in a relation. :param name: The name of the relationship :type name: str :type results: dict :rtype: dict """ progress = [] for segment in name.split('.'): pr...
python
def _parse_nested(self, name, results): """ Parse the nested relationship in a relation. :param name: The name of the relationship :type name: str :type results: dict :rtype: dict """ progress = [] for segment in name.split('.'): pr...
[ "def", "_parse_nested", "(", "self", ",", "name", ",", "results", ")", ":", "progress", "=", "[", "]", "for", "segment", "in", "name", ".", "split", "(", "'.'", ")", ":", "progress", ".", "append", "(", "segment", ")", "last", "=", "'.'", ".", "joi...
Parse the nested relationship in a relation. :param name: The name of the relationship :type name: str :type results: dict :rtype: dict
[ "Parse", "the", "nested", "relationship", "in", "a", "relation", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L736-L756
sdispater/eloquent
eloquent/orm/builder.py
Builder._call_scope
def _call_scope(self, scope, *args, **kwargs): """ Call the given model scope. :param scope: The scope to call :type scope: str """ result = getattr(self._model, scope)(self, *args, **kwargs) return result or self
python
def _call_scope(self, scope, *args, **kwargs): """ Call the given model scope. :param scope: The scope to call :type scope: str """ result = getattr(self._model, scope)(self, *args, **kwargs) return result or self
[ "def", "_call_scope", "(", "self", ",", "scope", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "getattr", "(", "self", ".", "_model", ",", "scope", ")", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "return", ...
Call the given model scope. :param scope: The scope to call :type scope: str
[ "Call", "the", "given", "model", "scope", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/builder.py#L758-L767
sdispater/eloquent
eloquent/migrations/migrator.py
Migrator._run_up
def _run_up(self, path, migration_file, batch, pretend=False): """ Run "up" a migration instance. :type migration_file: str :type batch: int :type pretend: bool """ migration = self._resolve(path, migration_file) if pretend: return self._pr...
python
def _run_up(self, path, migration_file, batch, pretend=False): """ Run "up" a migration instance. :type migration_file: str :type batch: int :type pretend: bool """ migration = self._resolve(path, migration_file) if pretend: return self._pr...
[ "def", "_run_up", "(", "self", ",", "path", ",", "migration_file", ",", "batch", ",", "pretend", "=", "False", ")", ":", "migration", "=", "self", ".", "_resolve", "(", "path", ",", "migration_file", ")", "if", "pretend", ":", "return", "self", ".", "_...
Run "up" a migration instance. :type migration_file: str :type batch: int :type pretend: bool
[ "Run", "up", "a", "migration", "instance", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/migrations/migrator.py#L69-L88
sdispater/eloquent
eloquent/migrations/migrator.py
Migrator.rollback
def rollback(self, path, pretend=False): """ Rollback the last migration operation. :param path: The path :type path: str :param pretend: Whether we execute the migrations as dry-run :type pretend: bool :rtype: int """ self._notes = [] ...
python
def rollback(self, path, pretend=False): """ Rollback the last migration operation. :param path: The path :type path: str :param pretend: Whether we execute the migrations as dry-run :type pretend: bool :rtype: int """ self._notes = [] ...
[ "def", "rollback", "(", "self", ",", "path", ",", "pretend", "=", "False", ")", ":", "self", ".", "_notes", "=", "[", "]", "migrations", "=", "self", ".", "_repository", ".", "get_last", "(", ")", "if", "not", "migrations", ":", "self", ".", "_note",...
Rollback the last migration operation. :param path: The path :type path: str :param pretend: Whether we execute the migrations as dry-run :type pretend: bool :rtype: int
[ "Rollback", "the", "last", "migration", "operation", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/migrations/migrator.py#L90-L114
sdispater/eloquent
eloquent/migrations/migrator.py
Migrator._run_down
def _run_down(self, path, migration, pretend=False): """ Run "down" a migration instance. """ migration_file = migration['migration'] instance = self._resolve(path, migration_file) if pretend: return self._pretend_to_run(instance, 'down') instance.d...
python
def _run_down(self, path, migration, pretend=False): """ Run "down" a migration instance. """ migration_file = migration['migration'] instance = self._resolve(path, migration_file) if pretend: return self._pretend_to_run(instance, 'down') instance.d...
[ "def", "_run_down", "(", "self", ",", "path", ",", "migration", ",", "pretend", "=", "False", ")", ":", "migration_file", "=", "migration", "[", "'migration'", "]", "instance", "=", "self", ".", "_resolve", "(", "path", ",", "migration_file", ")", "if", ...
Run "down" a migration instance.
[ "Run", "down", "a", "migration", "instance", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/migrations/migrator.py#L116-L131
sdispater/eloquent
eloquent/migrations/migrator.py
Migrator._pretend_to_run
def _pretend_to_run(self, migration, method): """ Pretend to run the migration. :param migration: The migration :type migration: eloquent.migrations.migration.Migration :param method: The method to execute :type method: str """ for query in self._get_que...
python
def _pretend_to_run(self, migration, method): """ Pretend to run the migration. :param migration: The migration :type migration: eloquent.migrations.migration.Migration :param method: The method to execute :type method: str """ for query in self._get_que...
[ "def", "_pretend_to_run", "(", "self", ",", "migration", ",", "method", ")", ":", "for", "query", "in", "self", ".", "_get_queries", "(", "migration", ",", "method", ")", ":", "name", "=", "migration", ".", "__class__", ".", "__name__", "self", ".", "_no...
Pretend to run the migration. :param migration: The migration :type migration: eloquent.migrations.migration.Migration :param method: The method to execute :type method: str
[ "Pretend", "to", "run", "the", "migration", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/migrations/migrator.py#L152-L165
sdispater/eloquent
eloquent/migrations/migrator.py
Migrator._get_queries
def _get_queries(self, migration, method): """ Get all of the queries that would be run for a migration. :param migration: The migration :type migration: eloquent.migrations.migration.Migration :param method: The method to execute :type method: str :rtype: list...
python
def _get_queries(self, migration, method): """ Get all of the queries that would be run for a migration. :param migration: The migration :type migration: eloquent.migrations.migration.Migration :param method: The method to execute :type method: str :rtype: list...
[ "def", "_get_queries", "(", "self", ",", "migration", ",", "method", ")", ":", "connection", "=", "migration", ".", "get_connection", "(", ")", "db", "=", "self", ".", "resolve_connection", "(", "connection", ")", "logger", "=", "logging", ".", "getLogger", ...
Get all of the queries that would be run for a migration. :param migration: The migration :type migration: eloquent.migrations.migration.Migration :param method: The method to execute :type method: str :rtype: list
[ "Get", "all", "of", "the", "queries", "that", "would", "be", "run", "for", "a", "migration", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/migrations/migrator.py#L167-L195
sdispater/eloquent
eloquent/migrations/migrator.py
Migrator._resolve
def _resolve(self, path, migration_file): """ Resolve a migration instance from a file. :param migration_file: The migration file :type migration_file: str :rtype: eloquent.migrations.migration.Migration """ variables = {} name = '_'.join(migration_file...
python
def _resolve(self, path, migration_file): """ Resolve a migration instance from a file. :param migration_file: The migration file :type migration_file: str :rtype: eloquent.migrations.migration.Migration """ variables = {} name = '_'.join(migration_file...
[ "def", "_resolve", "(", "self", ",", "path", ",", "migration_file", ")", ":", "variables", "=", "{", "}", "name", "=", "'_'", ".", "join", "(", "migration_file", ".", "split", "(", "'_'", ")", "[", "4", ":", "]", ")", "migration_file", "=", "os", "...
Resolve a migration instance from a file. :param migration_file: The migration file :type migration_file: str :rtype: eloquent.migrations.migration.Migration
[ "Resolve", "a", "migration", "instance", "from", "a", "file", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/migrations/migrator.py#L197-L219
sdispater/eloquent
eloquent/dbal/platforms/mysql_platform.py
MySqlPlatform.get_alter_table_sql
def get_alter_table_sql(self, diff): """ Get the ALTER TABLE SQL statement :param diff: The table diff :type diff: eloquent.dbal.table_diff.TableDiff :rtype: list """ column_sql = [] query_parts = [] if diff.new_name is not False: qu...
python
def get_alter_table_sql(self, diff): """ Get the ALTER TABLE SQL statement :param diff: The table diff :type diff: eloquent.dbal.table_diff.TableDiff :rtype: list """ column_sql = [] query_parts = [] if diff.new_name is not False: qu...
[ "def", "get_alter_table_sql", "(", "self", ",", "diff", ")", ":", "column_sql", "=", "[", "]", "query_parts", "=", "[", "]", "if", "diff", ".", "new_name", "is", "not", "False", ":", "query_parts", ".", "append", "(", "'RENAME TO %s'", "%", "diff", ".", ...
Get the ALTER TABLE SQL statement :param diff: The table diff :type diff: eloquent.dbal.table_diff.TableDiff :rtype: list
[ "Get", "the", "ALTER", "TABLE", "SQL", "statement" ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/dbal/platforms/mysql_platform.py#L85-L129
sdispater/eloquent
eloquent/dbal/comparator.py
Comparator.diff_table
def diff_table(self, table1, table2): """ Returns the difference between the tables table1 and table2. :type table1: Table :type table2: Table :rtype: TableDiff """ changes = 0 table_differences = TableDiff(table1.get_name()) table_differences.fr...
python
def diff_table(self, table1, table2): """ Returns the difference between the tables table1 and table2. :type table1: Table :type table2: Table :rtype: TableDiff """ changes = 0 table_differences = TableDiff(table1.get_name()) table_differences.fr...
[ "def", "diff_table", "(", "self", ",", "table1", ",", "table2", ")", ":", "changes", "=", "0", "table_differences", "=", "TableDiff", "(", "table1", ".", "get_name", "(", ")", ")", "table_differences", ".", "from_table", "=", "table1", "table1_columns", "=",...
Returns the difference between the tables table1 and table2. :type table1: Table :type table2: Table :rtype: TableDiff
[ "Returns", "the", "difference", "between", "the", "tables", "table1", "and", "table2", "." ]
train
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/dbal/comparator.py#L12-L110