repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
sdispater/orator | orator/orm/relations/belongs_to.py | BelongsTo.update | def update(self, _attributes=None, **attributes):
"""
Update the parent model on the relationship.
:param attributes: The update attributes
:type attributes: dict
:rtype: mixed
"""
if _attributes is not None:
attributes.update(_attributes)
i... | python | def update(self, _attributes=None, **attributes):
"""
Update the parent model on the relationship.
:param attributes: The update attributes
:type attributes: dict
:rtype: mixed
"""
if _attributes is not None:
attributes.update(_attributes)
i... | [
"def",
"update",
"(",
"self",
",",
"_attributes",
"=",
"None",
",",
"**",
"attributes",
")",
":",
"if",
"_attributes",
"is",
"not",
"None",
":",
"attributes",
".",
"update",
"(",
"_attributes",
")",
"instance",
"=",
"self",
".",
"get_results",
"(",
")",
... | Update the parent model on the relationship.
:param attributes: The update attributes
:type attributes: dict
:rtype: mixed | [
"Update",
"the",
"parent",
"model",
"on",
"the",
"relationship",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to.py#L177-L191 | train |
sdispater/orator | orator/orm/relations/morph_to.py | MorphTo._build_dictionary | def _build_dictionary(self, models):
"""
Build a dictionary with the models.
:param models: The models
:type models: Collection
"""
for model in models:
key = getattr(model, self._morph_type, None)
if key:
foreign = getattr(model, ... | python | def _build_dictionary(self, models):
"""
Build a dictionary with the models.
:param models: The models
:type models: Collection
"""
for model in models:
key = getattr(model, self._morph_type, None)
if key:
foreign = getattr(model, ... | [
"def",
"_build_dictionary",
"(",
"self",
",",
"models",
")",
":",
"for",
"model",
"in",
"models",
":",
"key",
"=",
"getattr",
"(",
"model",
",",
"self",
".",
"_morph_type",
",",
"None",
")",
"if",
"key",
":",
"foreign",
"=",
"getattr",
"(",
"model",
... | Build a dictionary with the models.
:param models: The models
:type models: Collection | [
"Build",
"a",
"dictionary",
"with",
"the",
"models",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/morph_to.py#L49-L66 | train |
sdispater/orator | orator/orm/relations/morph_to.py | MorphTo.get_eager | def get_eager(self):
"""
Get the relationship for eager loading.
:rtype: Collection
"""
for type in self._dictionary.keys():
self._match_to_morph_parents(type, self._get_results_by_type(type))
return self._models | python | def get_eager(self):
"""
Get the relationship for eager loading.
:rtype: Collection
"""
for type in self._dictionary.keys():
self._match_to_morph_parents(type, self._get_results_by_type(type))
return self._models | [
"def",
"get_eager",
"(",
"self",
")",
":",
"for",
"type",
"in",
"self",
".",
"_dictionary",
".",
"keys",
"(",
")",
":",
"self",
".",
"_match_to_morph_parents",
"(",
"type",
",",
"self",
".",
"_get_results_by_type",
"(",
"type",
")",
")",
"return",
"self"... | Get the relationship for eager loading.
:rtype: Collection | [
"Get",
"the",
"relationship",
"for",
"eager",
"loading",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/morph_to.py#L93-L102 | train |
sdispater/orator | orator/orm/relations/morph_to.py | MorphTo._match_to_morph_parents | def _match_to_morph_parents(self, type, results):
"""
Match the results for a given type to their parent.
:param type: The parent type
:type type: str
:param results: The results to match to their parent
:type results: Collection
"""
for result in result... | python | def _match_to_morph_parents(self, type, results):
"""
Match the results for a given type to their parent.
:param type: The parent type
:type type: str
:param results: The results to match to their parent
:type results: Collection
"""
for result in result... | [
"def",
"_match_to_morph_parents",
"(",
"self",
",",
"type",
",",
"results",
")",
":",
"for",
"result",
"in",
"results",
":",
"if",
"result",
".",
"get_key",
"(",
")",
"in",
"self",
".",
"_dictionary",
".",
"get",
"(",
"type",
",",
"[",
"]",
")",
":",... | Match the results for a given type to their parent.
:param type: The parent type
:type type: str
:param results: The results to match to their parent
:type results: Collection | [
"Match",
"the",
"results",
"for",
"a",
"given",
"type",
"to",
"their",
"parent",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/morph_to.py#L104-L119 | train |
sdispater/orator | orator/orm/relations/morph_to.py | MorphTo._get_results_by_type | def _get_results_by_type(self, type):
"""
Get all the relation results for a type.
:param type: The type
:type type: str
:rtype: Collection
"""
instance = self._create_model_by_type(type)
key = instance.get_key_name()
query = instance.new_query... | python | def _get_results_by_type(self, type):
"""
Get all the relation results for a type.
:param type: The type
:type type: str
:rtype: Collection
"""
instance = self._create_model_by_type(type)
key = instance.get_key_name()
query = instance.new_query... | [
"def",
"_get_results_by_type",
"(",
"self",
",",
"type",
")",
":",
"instance",
"=",
"self",
".",
"_create_model_by_type",
"(",
"type",
")",
"key",
"=",
"instance",
".",
"get_key_name",
"(",
")",
"query",
"=",
"instance",
".",
"new_query",
"(",
")",
"query"... | Get all the relation results for a type.
:param type: The type
:type type: str
:rtype: Collection | [
"Get",
"all",
"the",
"relation",
"results",
"for",
"a",
"type",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/morph_to.py#L121-L138 | train |
sdispater/orator | orator/orm/relations/morph_to.py | MorphTo._gather_keys_by_type | def _gather_keys_by_type(self, type):
"""
Gather all of the foreign keys for a given type.
:param type: The type
:type type: str
:rtype: BaseCollection
"""
foreign = self._foreign_key
keys = (
BaseCollection.make(list(self._dictionary[type].... | python | def _gather_keys_by_type(self, type):
"""
Gather all of the foreign keys for a given type.
:param type: The type
:type type: str
:rtype: BaseCollection
"""
foreign = self._foreign_key
keys = (
BaseCollection.make(list(self._dictionary[type].... | [
"def",
"_gather_keys_by_type",
"(",
"self",
",",
"type",
")",
":",
"foreign",
"=",
"self",
".",
"_foreign_key",
"keys",
"=",
"(",
"BaseCollection",
".",
"make",
"(",
"list",
"(",
"self",
".",
"_dictionary",
"[",
"type",
"]",
".",
"values",
"(",
")",
")... | Gather all of the foreign keys for a given type.
:param type: The type
:type type: str
:rtype: BaseCollection | [
"Gather",
"all",
"of",
"the",
"foreign",
"keys",
"for",
"a",
"given",
"type",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/morph_to.py#L140-L157 | train |
sdispater/orator | orator/dbal/table.py | Table.set_primary_key | def set_primary_key(self, columns, index_name=False):
"""
Set the primary key.
:type columns: list
:type index_name: str or bool
:rtype: Table
"""
self._add_index(
self._create_index(columns, index_name or "primary", True, True)
)
fo... | python | def set_primary_key(self, columns, index_name=False):
"""
Set the primary key.
:type columns: list
:type index_name: str or bool
:rtype: Table
"""
self._add_index(
self._create_index(columns, index_name or "primary", True, True)
)
fo... | [
"def",
"set_primary_key",
"(",
"self",
",",
"columns",
",",
"index_name",
"=",
"False",
")",
":",
"self",
".",
"_add_index",
"(",
"self",
".",
"_create_index",
"(",
"columns",
",",
"index_name",
"or",
"\"primary\"",
",",
"True",
",",
"True",
")",
")",
"f... | Set the primary key.
:type columns: list
:type index_name: str or bool
:rtype: Table | [
"Set",
"the",
"primary",
"key",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L55-L72 | train |
sdispater/orator | orator/dbal/table.py | Table.drop_index | def drop_index(self, name):
"""
Drops an index from this table.
:param name: The index name
:type name: str
"""
name = self._normalize_identifier(name)
if not self.has_index(name):
raise IndexDoesNotExist(name, self._name)
del self._indexes[n... | python | def drop_index(self, name):
"""
Drops an index from this table.
:param name: The index name
:type name: str
"""
name = self._normalize_identifier(name)
if not self.has_index(name):
raise IndexDoesNotExist(name, self._name)
del self._indexes[n... | [
"def",
"drop_index",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"self",
".",
"_normalize_identifier",
"(",
"name",
")",
"if",
"not",
"self",
".",
"has_index",
"(",
"name",
")",
":",
"raise",
"IndexDoesNotExist",
"(",
"name",
",",
"self",
".",
"_n... | Drops an index from this table.
:param name: The index name
:type name: str | [
"Drops",
"an",
"index",
"from",
"this",
"table",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L91-L102 | train |
sdispater/orator | orator/dbal/table.py | Table.rename_index | def rename_index(self, old_name, new_name=None):
"""
Renames an index.
:param old_name: The name of the index to rename from.
:type old_name: str
:param new_name: The name of the index to rename to.
:type new_name: str or None
:rtype: Table
"""
... | python | def rename_index(self, old_name, new_name=None):
"""
Renames an index.
:param old_name: The name of the index to rename from.
:type old_name: str
:param new_name: The name of the index to rename to.
:type new_name: str or None
:rtype: Table
"""
... | [
"def",
"rename_index",
"(",
"self",
",",
"old_name",
",",
"new_name",
"=",
"None",
")",
":",
"old_name",
"=",
"self",
".",
"_normalize_identifier",
"(",
"old_name",
")",
"normalized_new_name",
"=",
"self",
".",
"_normalize_identifier",
"(",
"new_name",
")",
"i... | Renames an index.
:param old_name: The name of the index to rename from.
:type old_name: str
:param new_name: The name of the index to rename to.
:type new_name: str or None
:rtype: Table | [
"Renames",
"an",
"index",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L114-L150 | train |
sdispater/orator | orator/dbal/table.py | Table.columns_are_indexed | def columns_are_indexed(self, columns):
"""
Checks if an index begins in the order of the given columns.
:type columns: list
:rtype: bool
"""
for index in self._indexes.values():
if index.spans_columns(columns):
return True
return Fa... | python | def columns_are_indexed(self, columns):
"""
Checks if an index begins in the order of the given columns.
:type columns: list
:rtype: bool
"""
for index in self._indexes.values():
if index.spans_columns(columns):
return True
return Fa... | [
"def",
"columns_are_indexed",
"(",
"self",
",",
"columns",
")",
":",
"for",
"index",
"in",
"self",
".",
"_indexes",
".",
"values",
"(",
")",
":",
"if",
"index",
".",
"spans_columns",
"(",
"columns",
")",
":",
"return",
"True",
"return",
"False"
] | Checks if an index begins in the order of the given columns.
:type columns: list
:rtype: bool | [
"Checks",
"if",
"an",
"index",
"begins",
"in",
"the",
"order",
"of",
"the",
"given",
"columns",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L152-L164 | train |
sdispater/orator | orator/dbal/table.py | Table._create_index | def _create_index(
self, columns, name, is_unique, is_primary, flags=None, options=None
):
"""
Creates an Index instance.
:param columns: The index columns
:type columns: list
:param name: The index name
:type name: str
:param is_unique: Whether the... | python | def _create_index(
self, columns, name, is_unique, is_primary, flags=None, options=None
):
"""
Creates an Index instance.
:param columns: The index columns
:type columns: list
:param name: The index name
:type name: str
:param is_unique: Whether the... | [
"def",
"_create_index",
"(",
"self",
",",
"columns",
",",
"name",
",",
"is_unique",
",",
"is_primary",
",",
"flags",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"if",
"re",
".",
"match",
"(",
"\"[^a-zA-Z0-9_]+\"",
",",
"self",
".",
"_normalize_id... | Creates an Index instance.
:param columns: The index columns
:type columns: list
:param name: The index name
:type name: str
:param is_unique: Whether the index is unique or not
:type is_unique: bool
:param is_primary: Whether the index is primary or not
... | [
"Creates",
"an",
"Index",
"instance",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L166-L202 | train |
sdispater/orator | orator/dbal/table.py | Table.add_column | def add_column(self, name, type_name, options=None):
"""
Adds a new column.
:param name: The column name
:type name: str
:param type_name: The column type
:type type_name: str
:param options: The column options
:type options: dict
:rtype: Colum... | python | def add_column(self, name, type_name, options=None):
"""
Adds a new column.
:param name: The column name
:type name: str
:param type_name: The column type
:type type_name: str
:param options: The column options
:type options: dict
:rtype: Colum... | [
"def",
"add_column",
"(",
"self",
",",
"name",
",",
"type_name",
",",
"options",
"=",
"None",
")",
":",
"column",
"=",
"Column",
"(",
"name",
",",
"type_name",
",",
"options",
")",
"self",
".",
"_add_column",
"(",
"column",
")",
"return",
"column"
] | Adds a new column.
:param name: The column name
:type name: str
:param type_name: The column type
:type type_name: str
:param options: The column options
:type options: dict
:rtype: Column | [
"Adds",
"a",
"new",
"column",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L204-L223 | train |
sdispater/orator | orator/dbal/table.py | Table.change_column | def change_column(self, name, options):
"""
Changes column details.
:param name: The column to change.
:type name: str
:param options: The new options.
:type options: str
:rtype: Table
"""
column = self.get_column(name)
column.set_option... | python | def change_column(self, name, options):
"""
Changes column details.
:param name: The column to change.
:type name: str
:param options: The new options.
:type options: str
:rtype: Table
"""
column = self.get_column(name)
column.set_option... | [
"def",
"change_column",
"(",
"self",
",",
"name",
",",
"options",
")",
":",
"column",
"=",
"self",
".",
"get_column",
"(",
"name",
")",
"column",
".",
"set_options",
"(",
"options",
")",
"return",
"self"
] | Changes column details.
:param name: The column to change.
:type name: str
:param options: The new options.
:type options: str
:rtype: Table | [
"Changes",
"column",
"details",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L225-L240 | train |
sdispater/orator | orator/dbal/table.py | Table.drop_column | def drop_column(self, name):
"""
Drops a Column from the Table
:param name: The name of the column
:type name: str
:rtype: Table
"""
name = self._normalize_identifier(name)
del self._columns[name]
return self | python | def drop_column(self, name):
"""
Drops a Column from the Table
:param name: The name of the column
:type name: str
:rtype: Table
"""
name = self._normalize_identifier(name)
del self._columns[name]
return self | [
"def",
"drop_column",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"self",
".",
"_normalize_identifier",
"(",
"name",
")",
"del",
"self",
".",
"_columns",
"[",
"name",
"]",
"return",
"self"
] | Drops a Column from the Table
:param name: The name of the column
:type name: str
:rtype: Table | [
"Drops",
"a",
"Column",
"from",
"the",
"Table"
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L242-L254 | train |
sdispater/orator | orator/dbal/table.py | Table.add_named_foreign_key_constraint | def add_named_foreign_key_constraint(
self, name, foreign_table, local_columns, foreign_columns, options
):
"""
Adds a foreign key constraint with a given name.
:param name: The constraint name
:type name: str
:param foreign_table: Table instance or table name
... | python | def add_named_foreign_key_constraint(
self, name, foreign_table, local_columns, foreign_columns, options
):
"""
Adds a foreign key constraint with a given name.
:param name: The constraint name
:type name: str
:param foreign_table: Table instance or table name
... | [
"def",
"add_named_foreign_key_constraint",
"(",
"self",
",",
"name",
",",
"foreign_table",
",",
"local_columns",
",",
"foreign_columns",
",",
"options",
")",
":",
"if",
"isinstance",
"(",
"foreign_table",
",",
"Table",
")",
":",
"for",
"column",
"in",
"foreign_c... | Adds a foreign key constraint with a given name.
:param name: The constraint name
:type name: str
:param foreign_table: Table instance or table name
:type foreign_table: Table or str
:type local_columns: list
:type foreign_columns: list
:type options: dict
... | [
"Adds",
"a",
"foreign",
"key",
"constraint",
"with",
"a",
"given",
"name",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L293-L328 | train |
sdispater/orator | orator/dbal/table.py | Table._add_index | def _add_index(self, index):
"""
Adds an index to the table.
:param index: The index to add
:type index: Index
:rtype: Table
"""
index_name = index.get_name()
index_name = self._normalize_identifier(index_name)
replaced_implicit_indexes = []
... | python | def _add_index(self, index):
"""
Adds an index to the table.
:param index: The index to add
:type index: Index
:rtype: Table
"""
index_name = index.get_name()
index_name = self._normalize_identifier(index_name)
replaced_implicit_indexes = []
... | [
"def",
"_add_index",
"(",
"self",
",",
"index",
")",
":",
"index_name",
"=",
"index",
".",
"get_name",
"(",
")",
"index_name",
"=",
"self",
".",
"_normalize_identifier",
"(",
"index_name",
")",
"replaced_implicit_indexes",
"=",
"[",
"]",
"for",
"name",
",",
... | Adds an index to the table.
:param index: The index to add
:type index: Index
:rtype: Table | [
"Adds",
"an",
"index",
"to",
"the",
"table",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L343-L378 | train |
sdispater/orator | orator/dbal/table.py | Table.has_foreign_key | def has_foreign_key(self, name):
"""
Returns whether this table has a foreign key constraint with the given name.
:param name: The constraint name
:type name: str
:rtype: bool
"""
name = self._normalize_identifier(name)
return name in self._fk_constrain... | python | def has_foreign_key(self, name):
"""
Returns whether this table has a foreign key constraint with the given name.
:param name: The constraint name
:type name: str
:rtype: bool
"""
name = self._normalize_identifier(name)
return name in self._fk_constrain... | [
"def",
"has_foreign_key",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"self",
".",
"_normalize_identifier",
"(",
"name",
")",
"return",
"name",
"in",
"self",
".",
"_fk_constraints"
] | Returns whether this table has a foreign key constraint with the given name.
:param name: The constraint name
:type name: str
:rtype: bool | [
"Returns",
"whether",
"this",
"table",
"has",
"a",
"foreign",
"key",
"constraint",
"with",
"the",
"given",
"name",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L428-L439 | train |
sdispater/orator | orator/dbal/table.py | Table.get_foreign_key | def get_foreign_key(self, name):
"""
Returns the foreign key constraint with the given name.
:param name: The constraint name
:type name: str
:rtype: ForeignKeyConstraint
"""
name = self._normalize_identifier(name)
if not self.has_foreign_key(name):
... | python | def get_foreign_key(self, name):
"""
Returns the foreign key constraint with the given name.
:param name: The constraint name
:type name: str
:rtype: ForeignKeyConstraint
"""
name = self._normalize_identifier(name)
if not self.has_foreign_key(name):
... | [
"def",
"get_foreign_key",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"self",
".",
"_normalize_identifier",
"(",
"name",
")",
"if",
"not",
"self",
".",
"has_foreign_key",
"(",
"name",
")",
":",
"raise",
"ForeignKeyDoesNotExist",
"(",
"name",
",",
"sel... | Returns the foreign key constraint with the given name.
:param name: The constraint name
:type name: str
:rtype: ForeignKeyConstraint | [
"Returns",
"the",
"foreign",
"key",
"constraint",
"with",
"the",
"given",
"name",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L441-L455 | train |
sdispater/orator | orator/dbal/table.py | Table.remove_foreign_key | def remove_foreign_key(self, name):
"""
Removes the foreign key constraint with the given name.
:param name: The constraint name
:type name: str
"""
name = self._normalize_identifier(name)
if not self.has_foreign_key(name):
raise ForeignKeyDoesNotExi... | python | def remove_foreign_key(self, name):
"""
Removes the foreign key constraint with the given name.
:param name: The constraint name
:type name: str
"""
name = self._normalize_identifier(name)
if not self.has_foreign_key(name):
raise ForeignKeyDoesNotExi... | [
"def",
"remove_foreign_key",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"self",
".",
"_normalize_identifier",
"(",
"name",
")",
"if",
"not",
"self",
".",
"has_foreign_key",
"(",
"name",
")",
":",
"raise",
"ForeignKeyDoesNotExist",
"(",
"name",
",",
"... | Removes the foreign key constraint with the given name.
:param name: The constraint name
:type name: str | [
"Removes",
"the",
"foreign",
"key",
"constraint",
"with",
"the",
"given",
"name",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L457-L469 | train |
sdispater/orator | orator/dbal/table.py | Table.get_primary_key_columns | def get_primary_key_columns(self):
"""
Returns the primary key columns.
:rtype: list
"""
if not self.has_primary_key():
raise DBALException('Table "%s" has no primary key.' % self.get_name())
return self.get_primary_key().get_columns() | python | def get_primary_key_columns(self):
"""
Returns the primary key columns.
:rtype: list
"""
if not self.has_primary_key():
raise DBALException('Table "%s" has no primary key.' % self.get_name())
return self.get_primary_key().get_columns() | [
"def",
"get_primary_key_columns",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"has_primary_key",
"(",
")",
":",
"raise",
"DBALException",
"(",
"'Table \"%s\" has no primary key.'",
"%",
"self",
".",
"get_name",
"(",
")",
")",
"return",
"self",
".",
"get_p... | Returns the primary key columns.
:rtype: list | [
"Returns",
"the",
"primary",
"key",
"columns",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L511-L520 | train |
sdispater/orator | orator/dbal/table.py | Table.has_index | def has_index(self, name):
"""
Returns whether this table has an Index with the given name.
:param name: The index name
:type name: str
:rtype: bool
"""
name = self._normalize_identifier(name)
return name in self._indexes | python | def has_index(self, name):
"""
Returns whether this table has an Index with the given name.
:param name: The index name
:type name: str
:rtype: bool
"""
name = self._normalize_identifier(name)
return name in self._indexes | [
"def",
"has_index",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"self",
".",
"_normalize_identifier",
"(",
"name",
")",
"return",
"name",
"in",
"self",
".",
"_indexes"
] | Returns whether this table has an Index with the given name.
:param name: The index name
:type name: str
:rtype: bool | [
"Returns",
"whether",
"this",
"table",
"has",
"an",
"Index",
"with",
"the",
"given",
"name",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L533-L544 | train |
sdispater/orator | orator/dbal/table.py | Table.get_index | def get_index(self, name):
"""
Returns the Index with the given name.
:param name: The index name
:type name: str
:rtype: Index
"""
name = self._normalize_identifier(name)
if not self.has_index(name):
raise IndexDoesNotExist(name, self._name)... | python | def get_index(self, name):
"""
Returns the Index with the given name.
:param name: The index name
:type name: str
:rtype: Index
"""
name = self._normalize_identifier(name)
if not self.has_index(name):
raise IndexDoesNotExist(name, self._name)... | [
"def",
"get_index",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"self",
".",
"_normalize_identifier",
"(",
"name",
")",
"if",
"not",
"self",
".",
"has_index",
"(",
"name",
")",
":",
"raise",
"IndexDoesNotExist",
"(",
"name",
",",
"self",
".",
"_na... | Returns the Index with the given name.
:param name: The index name
:type name: str
:rtype: Index | [
"Returns",
"the",
"Index",
"with",
"the",
"given",
"name",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L546-L559 | train |
sdispater/orator | orator/orm/builder.py | Builder.without_global_scope | def without_global_scope(self, scope):
"""
Remove a registered global scope.
:param scope: The scope to remove
:type scope: Scope or str
:rtype: Builder
"""
if isinstance(scope, basestring):
del self._scopes[scope]
return self
k... | python | def without_global_scope(self, scope):
"""
Remove a registered global scope.
:param scope: The scope to remove
:type scope: Scope or str
:rtype: Builder
"""
if isinstance(scope, basestring):
del self._scopes[scope]
return self
k... | [
"def",
"without_global_scope",
"(",
"self",
",",
"scope",
")",
":",
"if",
"isinstance",
"(",
"scope",
",",
"basestring",
")",
":",
"del",
"self",
".",
"_scopes",
"[",
"scope",
"]",
"return",
"self",
"keys",
"=",
"[",
"]",
"for",
"key",
",",
"value",
... | Remove a registered global scope.
:param scope: The scope to remove
:type scope: Scope or str
:rtype: Builder | [
"Remove",
"a",
"registered",
"global",
"scope",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L63-L85 | train |
sdispater/orator | orator/orm/builder.py | Builder.find_or_fail | def find_or_fail(self, id, columns=None):
"""
Find a model by its primary key or raise an exception
:param id: The primary key value
:type id: mixed
:param columns: The columns to retrieve
:type columns: list
:return: The found model
:rtype: orator.Mode... | python | def find_or_fail(self, id, columns=None):
"""
Find a model by its primary key or raise an exception
:param id: The primary key value
:type id: mixed
:param columns: The columns to retrieve
:type columns: list
:return: The found model
:rtype: orator.Mode... | [
"def",
"find_or_fail",
"(",
"self",
",",
"id",
",",
"columns",
"=",
"None",
")",
":",
"result",
"=",
"self",
".",
"find",
"(",
"id",
",",
"columns",
")",
"if",
"isinstance",
"(",
"id",
",",
"list",
")",
":",
"if",
"len",
"(",
"result",
")",
"==",... | Find a model by its primary key or raise an exception
:param id: The primary key value
:type id: mixed
:param columns: The columns to retrieve
:type columns: list
:return: The found model
:rtype: orator.Model
:raises: ModelNotFound | [
"Find",
"a",
"model",
"by",
"its",
"primary",
"key",
"or",
"raise",
"an",
"exception"
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L143-L166 | train |
sdispater/orator | orator/orm/builder.py | Builder.first_or_fail | def first_or_fail(self, columns=None):
"""
Execute the query and get the first result or raise an exception
:param columns: The columns to get
:type columns: list
:return: The result
:rtype: mixed
"""
model = self.first(columns)
if model is not ... | python | def first_or_fail(self, columns=None):
"""
Execute the query and get the first result or raise an exception
:param columns: The columns to get
:type columns: list
:return: The result
:rtype: mixed
"""
model = self.first(columns)
if model is not ... | [
"def",
"first_or_fail",
"(",
"self",
",",
"columns",
"=",
"None",
")",
":",
"model",
"=",
"self",
".",
"first",
"(",
"columns",
")",
"if",
"model",
"is",
"not",
"None",
":",
"return",
"model",
"raise",
"ModelNotFound",
"(",
"self",
".",
"_model",
".",
... | Execute the query and get the first result or raise an exception
:param columns: The columns to get
:type columns: list
:return: The result
:rtype: mixed | [
"Execute",
"the",
"query",
"and",
"get",
"the",
"first",
"result",
"or",
"raise",
"an",
"exception"
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L183-L198 | train |
sdispater/orator | orator/orm/builder.py | Builder.pluck | def pluck(self, column):
"""
Pluck a single column from the database.
:param column: THe column to pluck
:type column: str
:return: The column value
:rtype: mixed
"""
result = self.first([column])
if result:
return result[column] | python | def pluck(self, column):
"""
Pluck a single column from the database.
:param column: THe column to pluck
:type column: str
:return: The column value
:rtype: mixed
"""
result = self.first([column])
if result:
return result[column] | [
"def",
"pluck",
"(",
"self",
",",
"column",
")",
":",
"result",
"=",
"self",
".",
"first",
"(",
"[",
"column",
"]",
")",
"if",
"result",
":",
"return",
"result",
"[",
"column",
"]"
] | Pluck a single column from the database.
:param column: THe column to pluck
:type column: str
:return: The column value
:rtype: mixed | [
"Pluck",
"a",
"single",
"column",
"from",
"the",
"database",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L221-L234 | train |
sdispater/orator | orator/orm/builder.py | Builder._add_updated_at_column | def _add_updated_at_column(self, values):
"""
Add the "updated_at" column to a dictionary of values.
:param values: The values to update
:type values: dict
:return: The new dictionary of values
:rtype: dict
"""
if not self._model.uses_timestamps():
... | python | def _add_updated_at_column(self, values):
"""
Add the "updated_at" column to a dictionary of values.
:param values: The values to update
:type values: dict
:return: The new dictionary of values
:rtype: dict
"""
if not self._model.uses_timestamps():
... | [
"def",
"_add_updated_at_column",
"(",
"self",
",",
"values",
")",
":",
"if",
"not",
"self",
".",
"_model",
".",
"uses_timestamps",
"(",
")",
":",
"return",
"values",
"column",
"=",
"self",
".",
"_model",
".",
"get_updated_at_column",
"(",
")",
"if",
"\"upd... | Add the "updated_at" column to a dictionary of values.
:param values: The values to update
:type values: dict
:return: The new dictionary of values
:rtype: dict | [
"Add",
"the",
"updated_at",
"column",
"to",
"a",
"dictionary",
"of",
"values",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L401-L419 | train |
sdispater/orator | orator/orm/builder.py | Builder.delete | def delete(self):
"""
Delete a record from the database.
"""
if self._on_delete is not None:
return self._on_delete(self)
return self._query.delete() | python | def delete(self):
"""
Delete a record from the database.
"""
if self._on_delete is not None:
return self._on_delete(self)
return self._query.delete() | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"self",
".",
"_on_delete",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_on_delete",
"(",
"self",
")",
"return",
"self",
".",
"_query",
".",
"delete",
"(",
")"
] | Delete a record from the database. | [
"Delete",
"a",
"record",
"from",
"the",
"database",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L421-L428 | train |
sdispater/orator | orator/orm/builder.py | Builder.get_relation | def get_relation(self, relation):
"""
Get the relation instance for the given relation name.
:rtype: orator.orm.relations.Relation
"""
from .relations import Relation
with Relation.no_constraints(True):
rel = getattr(self.get_model(), relation)()
ne... | python | def get_relation(self, relation):
"""
Get the relation instance for the given relation name.
:rtype: orator.orm.relations.Relation
"""
from .relations import Relation
with Relation.no_constraints(True):
rel = getattr(self.get_model(), relation)()
ne... | [
"def",
"get_relation",
"(",
"self",
",",
"relation",
")",
":",
"from",
".",
"relations",
"import",
"Relation",
"with",
"Relation",
".",
"no_constraints",
"(",
"True",
")",
":",
"rel",
"=",
"getattr",
"(",
"self",
".",
"get_model",
"(",
")",
",",
"relatio... | Get the relation instance for the given relation name.
:rtype: orator.orm.relations.Relation | [
"Get",
"the",
"relation",
"instance",
"for",
"the",
"given",
"relation",
"name",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L500-L516 | train |
sdispater/orator | orator/orm/builder.py | Builder._nested_relations | def _nested_relations(self, relation):
"""
Get the deeply nested relations for a given top-level relation.
:rtype: dict
"""
nested = {}
for name, constraints in self._eager_load.items():
if self._is_nested(name, relation):
nested[name[len(rel... | python | def _nested_relations(self, relation):
"""
Get the deeply nested relations for a given top-level relation.
:rtype: dict
"""
nested = {}
for name, constraints in self._eager_load.items():
if self._is_nested(name, relation):
nested[name[len(rel... | [
"def",
"_nested_relations",
"(",
"self",
",",
"relation",
")",
":",
"nested",
"=",
"{",
"}",
"for",
"name",
",",
"constraints",
"in",
"self",
".",
"_eager_load",
".",
"items",
"(",
")",
":",
"if",
"self",
".",
"_is_nested",
"(",
"name",
",",
"relation"... | Get the deeply nested relations for a given top-level relation.
:rtype: dict | [
"Get",
"the",
"deeply",
"nested",
"relations",
"for",
"a",
"given",
"top",
"-",
"level",
"relation",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L518-L530 | train |
sdispater/orator | orator/orm/builder.py | Builder._is_nested | def _is_nested(self, name, relation):
"""
Determine if the relationship is nested.
:type name: str
:type relation: str
:rtype: bool
"""
dots = name.find(".")
return dots and name.startswith(relation + ".") | python | def _is_nested(self, name, relation):
"""
Determine if the relationship is nested.
:type name: str
:type relation: str
:rtype: bool
"""
dots = name.find(".")
return dots and name.startswith(relation + ".") | [
"def",
"_is_nested",
"(",
"self",
",",
"name",
",",
"relation",
")",
":",
"dots",
"=",
"name",
".",
"find",
"(",
"\".\"",
")",
"return",
"dots",
"and",
"name",
".",
"startswith",
"(",
"relation",
"+",
"\".\"",
")"
] | Determine if the relationship is nested.
:type name: str
:type relation: str
:rtype: bool | [
"Determine",
"if",
"the",
"relationship",
"is",
"nested",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L532-L543 | train |
sdispater/orator | orator/orm/builder.py | Builder.where_exists | def where_exists(self, query, boolean="and", negate=False):
"""
Add an exists clause to the query.
:param query: The exists query
:type query: Builder or QueryBuilder
:type boolean: str
:type negate: bool
:rtype: Builder
"""
if isinstance(query... | python | def where_exists(self, query, boolean="and", negate=False):
"""
Add an exists clause to the query.
:param query: The exists query
:type query: Builder or QueryBuilder
:type boolean: str
:type negate: bool
:rtype: Builder
"""
if isinstance(query... | [
"def",
"where_exists",
"(",
"self",
",",
"query",
",",
"boolean",
"=",
"\"and\"",
",",
"negate",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"query",
",",
"Builder",
")",
":",
"query",
"=",
"query",
".",
"get_query",
"(",
")",
"self",
".",
"get_... | Add an exists clause to the query.
:param query: The exists query
:type query: Builder or QueryBuilder
:type boolean: str
:type negate: bool
:rtype: Builder | [
"Add",
"an",
"exists",
"clause",
"to",
"the",
"query",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L589-L607 | train |
sdispater/orator | orator/orm/builder.py | Builder.has | def has(self, relation, operator=">=", count=1, boolean="and", extra=None):
"""
Add a relationship count condition to the query.
:param relation: The relation to count
:type relation: str
:param operator: The operator
:type operator: str
:param count: The count... | python | def has(self, relation, operator=">=", count=1, boolean="and", extra=None):
"""
Add a relationship count condition to the query.
:param relation: The relation to count
:type relation: str
:param operator: The operator
:type operator: str
:param count: The count... | [
"def",
"has",
"(",
"self",
",",
"relation",
",",
"operator",
"=",
"\">=\"",
",",
"count",
"=",
"1",
",",
"boolean",
"=",
"\"and\"",
",",
"extra",
"=",
"None",
")",
":",
"if",
"relation",
".",
"find",
"(",
"\".\"",
")",
">=",
"0",
":",
"return",
"... | Add a relationship count condition to the query.
:param relation: The relation to count
:type relation: str
:param operator: The operator
:type operator: str
:param count: The count
:type count: int
:param boolean: The boolean value
:type boolean: str
... | [
"Add",
"a",
"relationship",
"count",
"condition",
"to",
"the",
"query",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L646-L683 | train |
sdispater/orator | orator/orm/builder.py | Builder._add_has_where | def _add_has_where(self, has_query, relation, operator, count, boolean):
"""
Add the "has" condition where clause to the query.
:param has_query: The has query
:type has_query: Builder
:param relation: The relation to count
:type relation: orator.orm.relations.Relation
... | python | def _add_has_where(self, has_query, relation, operator, count, boolean):
"""
Add the "has" condition where clause to the query.
:param has_query: The has query
:type has_query: Builder
:param relation: The relation to count
:type relation: orator.orm.relations.Relation
... | [
"def",
"_add_has_where",
"(",
"self",
",",
"has_query",
",",
"relation",
",",
"operator",
",",
"count",
",",
"boolean",
")",
":",
"self",
".",
"_merge_model_defined_relation_wheres_to_has_query",
"(",
"has_query",
",",
"relation",
")",
"if",
"isinstance",
"(",
"... | Add the "has" condition where clause to the query.
:param has_query: The has query
:type has_query: Builder
:param relation: The relation to count
:type relation: orator.orm.relations.Relation
:param operator: The operator
:type operator: str
:param count: The... | [
"Add",
"the",
"has",
"condition",
"where",
"clause",
"to",
"the",
"query",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L804-L832 | train |
sdispater/orator | orator/orm/builder.py | Builder._merge_model_defined_relation_wheres_to_has_query | def _merge_model_defined_relation_wheres_to_has_query(self, has_query, relation):
"""
Merge the "wheres" from a relation query to a has query.
:param has_query: The has query
:type has_query: Builder
:param relation: The relation to count
:type relation: orator.orm.rela... | python | def _merge_model_defined_relation_wheres_to_has_query(self, has_query, relation):
"""
Merge the "wheres" from a relation query to a has query.
:param has_query: The has query
:type has_query: Builder
:param relation: The relation to count
:type relation: orator.orm.rela... | [
"def",
"_merge_model_defined_relation_wheres_to_has_query",
"(",
"self",
",",
"has_query",
",",
"relation",
")",
":",
"relation_query",
"=",
"relation",
".",
"get_base_query",
"(",
")",
"has_query",
".",
"merge_wheres",
"(",
"relation_query",
".",
"wheres",
",",
"re... | Merge the "wheres" from a relation query to a has query.
:param has_query: The has query
:type has_query: Builder
:param relation: The relation to count
:type relation: orator.orm.relations.Relation | [
"Merge",
"the",
"wheres",
"from",
"a",
"relation",
"query",
"to",
"a",
"has",
"query",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L834-L848 | train |
sdispater/orator | orator/orm/builder.py | Builder.apply_scopes | def apply_scopes(self):
"""
Get the underlying query builder instance with applied global scopes.
:type: Builder
"""
if not self._scopes:
return self
builder = copy.copy(self)
query = builder.get_query()
# We will keep track of how many whe... | python | def apply_scopes(self):
"""
Get the underlying query builder instance with applied global scopes.
:type: Builder
"""
if not self._scopes:
return self
builder = copy.copy(self)
query = builder.get_query()
# We will keep track of how many whe... | [
"def",
"apply_scopes",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_scopes",
":",
"return",
"self",
"builder",
"=",
"copy",
".",
"copy",
"(",
"self",
")",
"query",
"=",
"builder",
".",
"get_query",
"(",
")",
"original_where_count",
"=",
"len",
"(... | Get the underlying query builder instance with applied global scopes.
:type: Builder | [
"Get",
"the",
"underlying",
"query",
"builder",
"instance",
"with",
"applied",
"global",
"scopes",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L953-L984 | train |
sdispater/orator | orator/orm/builder.py | Builder._apply_scope | def _apply_scope(self, scope, builder):
"""
Apply a single scope on the given builder instance.
:param scope: The scope to apply
:type scope: callable or Scope
:param builder: The builder to apply the scope to
:type builder: Builder
"""
if callable(scope... | python | def _apply_scope(self, scope, builder):
"""
Apply a single scope on the given builder instance.
:param scope: The scope to apply
:type scope: callable or Scope
:param builder: The builder to apply the scope to
:type builder: Builder
"""
if callable(scope... | [
"def",
"_apply_scope",
"(",
"self",
",",
"scope",
",",
"builder",
")",
":",
"if",
"callable",
"(",
"scope",
")",
":",
"scope",
"(",
"builder",
")",
"elif",
"isinstance",
"(",
"scope",
",",
"Scope",
")",
":",
"scope",
".",
"apply",
"(",
"builder",
","... | Apply a single scope on the given builder instance.
:param scope: The scope to apply
:type scope: callable or Scope
:param builder: The builder to apply the scope to
:type builder: Builder | [
"Apply",
"a",
"single",
"scope",
"on",
"the",
"given",
"builder",
"instance",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L986-L999 | train |
sdispater/orator | orator/orm/builder.py | Builder._nest_wheres_for_scope | def _nest_wheres_for_scope(self, query, where_counts):
"""
Nest where conditions of the builder and each global scope.
:type query: QueryBuilder
:type where_counts: list
"""
# Here, we totally remove all of the where clauses since we are going to
# rebuild them a... | python | def _nest_wheres_for_scope(self, query, where_counts):
"""
Nest where conditions of the builder and each global scope.
:type query: QueryBuilder
:type where_counts: list
"""
# Here, we totally remove all of the where clauses since we are going to
# rebuild them a... | [
"def",
"_nest_wheres_for_scope",
"(",
"self",
",",
"query",
",",
"where_counts",
")",
":",
"wheres",
"=",
"query",
".",
"wheres",
"query",
".",
"wheres",
"=",
"[",
"]",
"previous_count",
"=",
"where_counts",
".",
"pop",
"(",
"0",
")",
"for",
"where_count",... | Nest where conditions of the builder and each global scope.
:type query: QueryBuilder
:type where_counts: list | [
"Nest",
"where",
"conditions",
"of",
"the",
"builder",
"and",
"each",
"global",
"scope",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L1012-L1038 | train |
sdispater/orator | orator/orm/builder.py | Builder._slice_where_conditions | def _slice_where_conditions(self, wheres, offset, length):
"""
Create a where list with sliced where conditions.
:type wheres: list
:type offset: int
:type length: int
:rtype: list
"""
where_group = self.get_query().for_nested_where()
where_group... | python | def _slice_where_conditions(self, wheres, offset, length):
"""
Create a where list with sliced where conditions.
:type wheres: list
:type offset: int
:type length: int
:rtype: list
"""
where_group = self.get_query().for_nested_where()
where_group... | [
"def",
"_slice_where_conditions",
"(",
"self",
",",
"wheres",
",",
"offset",
",",
"length",
")",
":",
"where_group",
"=",
"self",
".",
"get_query",
"(",
")",
".",
"for_nested_where",
"(",
")",
"where_group",
".",
"wheres",
"=",
"wheres",
"[",
"offset",
":"... | Create a where list with sliced where conditions.
:type wheres: list
:type offset: int
:type length: int
:rtype: list | [
"Create",
"a",
"where",
"list",
"with",
"sliced",
"where",
"conditions",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L1040-L1053 | train |
sdispater/orator | orator/orm/builder.py | Builder.set_model | def set_model(self, model):
"""
Set a model instance for the model being queried.
:param model: The model instance
:type model: orator.orm.Model
:return: The current Builder instance
:rtype: Builder
"""
self._model = model
self._query.from_(mode... | python | def set_model(self, model):
"""
Set a model instance for the model being queried.
:param model: The model instance
:type model: orator.orm.Model
:return: The current Builder instance
:rtype: Builder
"""
self._model = model
self._query.from_(mode... | [
"def",
"set_model",
"(",
"self",
",",
"model",
")",
":",
"self",
".",
"_model",
"=",
"model",
"self",
".",
"_query",
".",
"from_",
"(",
"model",
".",
"get_table",
"(",
")",
")",
"return",
"self"
] | Set a model instance for the model being queried.
:param model: The model instance
:type model: orator.orm.Model
:return: The current Builder instance
:rtype: Builder | [
"Set",
"a",
"model",
"instance",
"for",
"the",
"model",
"being",
"queried",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L1108-L1122 | train |
sdispater/orator | orator/query/grammars/sqlite_grammar.py | SQLiteQueryGrammar.compile_insert | def compile_insert(self, query, values):
"""
Compile insert statement into SQL
:param query: A QueryBuilder instance
:type query: QueryBuilder
:param values: The insert values
:type values: dict or list
:return: The compiled insert
:rtype: str
"... | python | def compile_insert(self, query, values):
"""
Compile insert statement into SQL
:param query: A QueryBuilder instance
:type query: QueryBuilder
:param values: The insert values
:type values: dict or list
:return: The compiled insert
:rtype: str
"... | [
"def",
"compile_insert",
"(",
"self",
",",
"query",
",",
"values",
")",
":",
"table",
"=",
"self",
".",
"wrap_table",
"(",
"query",
".",
"from__",
")",
"if",
"not",
"isinstance",
"(",
"values",
",",
"list",
")",
":",
"values",
"=",
"[",
"values",
"]"... | Compile insert statement into SQL
:param query: A QueryBuilder instance
:type query: QueryBuilder
:param values: The insert values
:type values: dict or list
:return: The compiled insert
:rtype: str | [
"Compile",
"insert",
"statement",
"into",
"SQL"
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/grammars/sqlite_grammar.py#L26-L64 | train |
sdispater/orator | orator/query/grammars/sqlite_grammar.py | SQLiteQueryGrammar.compile_truncate | def compile_truncate(self, query):
"""
Compile a truncate statement into SQL
:param query: A QueryBuilder instance
:type query: QueryBuilder
:return: The compiled truncate statement
:rtype: str
"""
sql = {
"DELETE FROM sqlite_sequence WHERE n... | python | def compile_truncate(self, query):
"""
Compile a truncate statement into SQL
:param query: A QueryBuilder instance
:type query: QueryBuilder
:return: The compiled truncate statement
:rtype: str
"""
sql = {
"DELETE FROM sqlite_sequence WHERE n... | [
"def",
"compile_truncate",
"(",
"self",
",",
"query",
")",
":",
"sql",
"=",
"{",
"\"DELETE FROM sqlite_sequence WHERE name = %s\"",
"%",
"self",
".",
"get_marker",
"(",
")",
":",
"[",
"query",
".",
"from__",
"]",
"}",
"sql",
"[",
"\"DELETE FROM %s\"",
"%",
"... | Compile a truncate statement into SQL
:param query: A QueryBuilder instance
:type query: QueryBuilder
:return: The compiled truncate statement
:rtype: str | [
"Compile",
"a",
"truncate",
"statement",
"into",
"SQL"
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/grammars/sqlite_grammar.py#L66-L83 | train |
sdispater/orator | orator/schema/blueprint.py | Blueprint.build | def build(self, connection, grammar):
"""
Execute the blueprint against the database.
:param connection: The connection to use
:type connection: orator.connections.Connection
:param grammar: The grammar to user
:type grammar: orator.query.grammars.QueryGrammar
"... | python | def build(self, connection, grammar):
"""
Execute the blueprint against the database.
:param connection: The connection to use
:type connection: orator.connections.Connection
:param grammar: The grammar to user
:type grammar: orator.query.grammars.QueryGrammar
"... | [
"def",
"build",
"(",
"self",
",",
"connection",
",",
"grammar",
")",
":",
"for",
"statement",
"in",
"self",
".",
"to_sql",
"(",
"connection",
",",
"grammar",
")",
":",
"connection",
".",
"statement",
"(",
"statement",
")"
] | Execute the blueprint against the database.
:param connection: The connection to use
:type connection: orator.connections.Connection
:param grammar: The grammar to user
:type grammar: orator.query.grammars.QueryGrammar | [
"Execute",
"the",
"blueprint",
"against",
"the",
"database",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L19-L30 | train |
sdispater/orator | orator/schema/blueprint.py | Blueprint.to_sql | def to_sql(self, connection, grammar):
"""
Get the raw SQL statements for the blueprint.
:param connection: The connection to use
:type connection: orator.connections.Connection
:param grammar: The grammar to user
:type grammar: orator.schema.grammars.SchemaGrammar
... | python | def to_sql(self, connection, grammar):
"""
Get the raw SQL statements for the blueprint.
:param connection: The connection to use
:type connection: orator.connections.Connection
:param grammar: The grammar to user
:type grammar: orator.schema.grammars.SchemaGrammar
... | [
"def",
"to_sql",
"(",
"self",
",",
"connection",
",",
"grammar",
")",
":",
"self",
".",
"_add_implied_commands",
"(",
")",
"statements",
"=",
"[",
"]",
"for",
"command",
"in",
"self",
".",
"_commands",
":",
"method",
"=",
"\"compile_%s\"",
"%",
"command",
... | Get the raw SQL statements for the blueprint.
:param connection: The connection to use
:type connection: orator.connections.Connection
:param grammar: The grammar to user
:type grammar: orator.schema.grammars.SchemaGrammar
:rtype: list | [
"Get",
"the",
"raw",
"SQL",
"statements",
"for",
"the",
"blueprint",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L32-L59 | train |
sdispater/orator | orator/schema/blueprint.py | Blueprint._add_implied_commands | def _add_implied_commands(self):
"""
Add the commands that are implied by the blueprint.
"""
if len(self.get_added_columns()) and not self._creating():
self._commands.insert(0, self._create_command("add"))
if len(self.get_changed_columns()) and not self._creating():
... | python | def _add_implied_commands(self):
"""
Add the commands that are implied by the blueprint.
"""
if len(self.get_added_columns()) and not self._creating():
self._commands.insert(0, self._create_command("add"))
if len(self.get_changed_columns()) and not self._creating():
... | [
"def",
"_add_implied_commands",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"get_added_columns",
"(",
")",
")",
"and",
"not",
"self",
".",
"_creating",
"(",
")",
":",
"self",
".",
"_commands",
".",
"insert",
"(",
"0",
",",
"self",
".",
"_cr... | Add the commands that are implied by the blueprint. | [
"Add",
"the",
"commands",
"that",
"are",
"implied",
"by",
"the",
"blueprint",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L61-L71 | train |
sdispater/orator | orator/schema/blueprint.py | Blueprint.drop_column | def drop_column(self, *columns):
"""
Indicates that the given columns should be dropped.
:param columns: The columns to drop
:type columns: tuple
:rtype: Fluent
"""
columns = list(columns)
return self._add_command("drop_column", columns=columns) | python | def drop_column(self, *columns):
"""
Indicates that the given columns should be dropped.
:param columns: The columns to drop
:type columns: tuple
:rtype: Fluent
"""
columns = list(columns)
return self._add_command("drop_column", columns=columns) | [
"def",
"drop_column",
"(",
"self",
",",
"*",
"columns",
")",
":",
"columns",
"=",
"list",
"(",
"columns",
")",
"return",
"self",
".",
"_add_command",
"(",
"\"drop_column\"",
",",
"columns",
"=",
"columns",
")"
] | Indicates that the given columns should be dropped.
:param columns: The columns to drop
:type columns: tuple
:rtype: Fluent | [
"Indicates",
"that",
"the",
"given",
"columns",
"should",
"be",
"dropped",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L128-L139 | train |
sdispater/orator | orator/schema/blueprint.py | Blueprint.integer | def integer(self, column, auto_increment=False, unsigned=False):
"""
Create a new integer column on the table.
:param column: The column
:type column: str
:type auto_increment: bool
:type unsigned: bool
:rtype: Fluent
"""
return self._add_colum... | python | def integer(self, column, auto_increment=False, unsigned=False):
"""
Create a new integer column on the table.
:param column: The column
:type column: str
:type auto_increment: bool
:type unsigned: bool
:rtype: Fluent
"""
return self._add_colum... | [
"def",
"integer",
"(",
"self",
",",
"column",
",",
"auto_increment",
"=",
"False",
",",
"unsigned",
"=",
"False",
")",
":",
"return",
"self",
".",
"_add_column",
"(",
"\"integer\"",
",",
"column",
",",
"auto_increment",
"=",
"auto_increment",
",",
"unsigned"... | Create a new integer column on the table.
:param column: The column
:type column: str
:type auto_increment: bool
:type unsigned: bool
:rtype: Fluent | [
"Create",
"a",
"new",
"integer",
"column",
"on",
"the",
"table",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L358-L373 | train |
sdispater/orator | orator/schema/blueprint.py | Blueprint.small_integer | def small_integer(self, column, auto_increment=False, unsigned=False):
"""
Create a new small integer column on the table.
:param column: The column
:type column: str
:type auto_increment: bool
:type unsigned: bool
:rtype: Fluent
"""
return sel... | python | def small_integer(self, column, auto_increment=False, unsigned=False):
"""
Create a new small integer column on the table.
:param column: The column
:type column: str
:type auto_increment: bool
:type unsigned: bool
:rtype: Fluent
"""
return sel... | [
"def",
"small_integer",
"(",
"self",
",",
"column",
",",
"auto_increment",
"=",
"False",
",",
"unsigned",
"=",
"False",
")",
":",
"return",
"self",
".",
"_add_column",
"(",
"\"small_integer\"",
",",
"column",
",",
"auto_increment",
"=",
"auto_increment",
",",
... | Create a new small integer column on the table.
:param column: The column
:type column: str
:type auto_increment: bool
:type unsigned: bool
:rtype: Fluent | [
"Create",
"a",
"new",
"small",
"integer",
"column",
"on",
"the",
"table",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L426-L441 | train |
sdispater/orator | orator/schema/blueprint.py | Blueprint.unsigned_integer | def unsigned_integer(self, column, auto_increment=False):
"""
Create a new unisgned integer column on the table.
:param column: The column
:type column: str
:type auto_increment: bool
:rtype: Fluent
"""
return self.integer(column, auto_increment, True) | python | def unsigned_integer(self, column, auto_increment=False):
"""
Create a new unisgned integer column on the table.
:param column: The column
:type column: str
:type auto_increment: bool
:rtype: Fluent
"""
return self.integer(column, auto_increment, True) | [
"def",
"unsigned_integer",
"(",
"self",
",",
"column",
",",
"auto_increment",
"=",
"False",
")",
":",
"return",
"self",
".",
"integer",
"(",
"column",
",",
"auto_increment",
",",
"True",
")"
] | Create a new unisgned integer column on the table.
:param column: The column
:type column: str
:type auto_increment: bool
:rtype: Fluent | [
"Create",
"a",
"new",
"unisgned",
"integer",
"column",
"on",
"the",
"table",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L443-L454 | train |
sdispater/orator | orator/schema/blueprint.py | Blueprint.unsigned_big_integer | def unsigned_big_integer(self, column, auto_increment=False):
"""
Create a new unsigned big integer column on the table.
:param column: The column
:type column: str
:type auto_increment: bool
:rtype: Fluent
"""
return self.big_integer(column, auto_incre... | python | def unsigned_big_integer(self, column, auto_increment=False):
"""
Create a new unsigned big integer column on the table.
:param column: The column
:type column: str
:type auto_increment: bool
:rtype: Fluent
"""
return self.big_integer(column, auto_incre... | [
"def",
"unsigned_big_integer",
"(",
"self",
",",
"column",
",",
"auto_increment",
"=",
"False",
")",
":",
"return",
"self",
".",
"big_integer",
"(",
"column",
",",
"auto_increment",
",",
"True",
")"
] | Create a new unsigned big integer column on the table.
:param column: The column
:type column: str
:type auto_increment: bool
:rtype: Fluent | [
"Create",
"a",
"new",
"unsigned",
"big",
"integer",
"column",
"on",
"the",
"table",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L456-L467 | train |
sdispater/orator | orator/schema/blueprint.py | Blueprint.float | def float(self, column, total=8, places=2):
"""
Create a new float column on the table.
:param column: The column
:type column: str
:type total: int
:type places: 2
:rtype: Fluent
"""
return self._add_column("float", column, total=total, places... | python | def float(self, column, total=8, places=2):
"""
Create a new float column on the table.
:param column: The column
:type column: str
:type total: int
:type places: 2
:rtype: Fluent
"""
return self._add_column("float", column, total=total, places... | [
"def",
"float",
"(",
"self",
",",
"column",
",",
"total",
"=",
"8",
",",
"places",
"=",
"2",
")",
":",
"return",
"self",
".",
"_add_column",
"(",
"\"float\"",
",",
"column",
",",
"total",
"=",
"total",
",",
"places",
"=",
"places",
")"
] | Create a new float column on the table.
:param column: The column
:type column: str
:type total: int
:type places: 2
:rtype: Fluent | [
"Create",
"a",
"new",
"float",
"column",
"on",
"the",
"table",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L469-L482 | train |
sdispater/orator | orator/schema/blueprint.py | Blueprint.double | def double(self, column, total=None, places=None):
"""
Create a new double column on the table.
:param column: The column
:type column: str
:type total: int
:type places: 2
:rtype: Fluent
"""
return self._add_column("double", column, total=tota... | python | def double(self, column, total=None, places=None):
"""
Create a new double column on the table.
:param column: The column
:type column: str
:type total: int
:type places: 2
:rtype: Fluent
"""
return self._add_column("double", column, total=tota... | [
"def",
"double",
"(",
"self",
",",
"column",
",",
"total",
"=",
"None",
",",
"places",
"=",
"None",
")",
":",
"return",
"self",
".",
"_add_column",
"(",
"\"double\"",
",",
"column",
",",
"total",
"=",
"total",
",",
"places",
"=",
"places",
")"
] | Create a new double column on the table.
:param column: The column
:type column: str
:type total: int
:type places: 2
:rtype: Fluent | [
"Create",
"a",
"new",
"double",
"column",
"on",
"the",
"table",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L484-L497 | train |
sdispater/orator | orator/schema/blueprint.py | Blueprint.decimal | def decimal(self, column, total=8, places=2):
"""
Create a new decimal column on the table.
:param column: The column
:type column: str
:type total: int
:type places: 2
:rtype: Fluent
"""
return self._add_column("decimal", column, total=total, ... | python | def decimal(self, column, total=8, places=2):
"""
Create a new decimal column on the table.
:param column: The column
:type column: str
:type total: int
:type places: 2
:rtype: Fluent
"""
return self._add_column("decimal", column, total=total, ... | [
"def",
"decimal",
"(",
"self",
",",
"column",
",",
"total",
"=",
"8",
",",
"places",
"=",
"2",
")",
":",
"return",
"self",
".",
"_add_column",
"(",
"\"decimal\"",
",",
"column",
",",
"total",
"=",
"total",
",",
"places",
"=",
"places",
")"
] | Create a new decimal column on the table.
:param column: The column
:type column: str
:type total: int
:type places: 2
:rtype: Fluent | [
"Create",
"a",
"new",
"decimal",
"column",
"on",
"the",
"table",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L499-L512 | train |
sdispater/orator | orator/schema/blueprint.py | Blueprint.timestamps | def timestamps(self, use_current=True):
"""
Create creation and update timestamps to the table.
:rtype: Fluent
"""
if use_current:
self.timestamp("created_at").use_current()
self.timestamp("updated_at").use_current()
else:
self.timesta... | python | def timestamps(self, use_current=True):
"""
Create creation and update timestamps to the table.
:rtype: Fluent
"""
if use_current:
self.timestamp("created_at").use_current()
self.timestamp("updated_at").use_current()
else:
self.timesta... | [
"def",
"timestamps",
"(",
"self",
",",
"use_current",
"=",
"True",
")",
":",
"if",
"use_current",
":",
"self",
".",
"timestamp",
"(",
"\"created_at\"",
")",
".",
"use_current",
"(",
")",
"self",
".",
"timestamp",
"(",
"\"updated_at\"",
")",
".",
"use_curre... | Create creation and update timestamps to the table.
:rtype: Fluent | [
"Create",
"creation",
"and",
"update",
"timestamps",
"to",
"the",
"table",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L602-L613 | train |
sdispater/orator | orator/schema/blueprint.py | Blueprint.morphs | def morphs(self, name, index_name=None):
"""
Add the proper columns for a polymorphic table.
:type name: str
:type index_name: str
"""
self.unsigned_integer("%s_id" % name)
self.string("%s_type" % name)
self.index(["%s_id" % name, "%s_type" % name], inde... | python | def morphs(self, name, index_name=None):
"""
Add the proper columns for a polymorphic table.
:type name: str
:type index_name: str
"""
self.unsigned_integer("%s_id" % name)
self.string("%s_type" % name)
self.index(["%s_id" % name, "%s_type" % name], inde... | [
"def",
"morphs",
"(",
"self",
",",
"name",
",",
"index_name",
"=",
"None",
")",
":",
"self",
".",
"unsigned_integer",
"(",
"\"%s_id\"",
"%",
"name",
")",
"self",
".",
"string",
"(",
"\"%s_type\"",
"%",
"name",
")",
"self",
".",
"index",
"(",
"[",
"\"... | Add the proper columns for a polymorphic table.
:type name: str
:type index_name: str | [
"Add",
"the",
"proper",
"columns",
"for",
"a",
"polymorphic",
"table",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L634-L644 | train |
sdispater/orator | orator/schema/blueprint.py | Blueprint._drop_index_command | def _drop_index_command(self, command, type, index):
"""
Create a new drop index command on the blueprint.
:param command: The command
:type command: str
:param type: The index type
:type type: str
:param index: The index name
:type index: str
... | python | def _drop_index_command(self, command, type, index):
"""
Create a new drop index command on the blueprint.
:param command: The command
:type command: str
:param type: The index type
:type type: str
:param index: The index name
:type index: str
... | [
"def",
"_drop_index_command",
"(",
"self",
",",
"command",
",",
"type",
",",
"index",
")",
":",
"columns",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"index",
",",
"list",
")",
":",
"columns",
"=",
"index",
"index",
"=",
"self",
".",
"_create_index_name",
... | Create a new drop index command on the blueprint.
:param command: The command
:type command: str
:param type: The index type
:type type: str
:param index: The index name
:type index: str
:rtype: Fluent | [
"Create",
"a",
"new",
"drop",
"index",
"command",
"on",
"the",
"blueprint",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L646-L668 | train |
sdispater/orator | orator/schema/blueprint.py | Blueprint._index_command | def _index_command(self, type, columns, index):
"""
Add a new index command to the blueprint.
:param type: The index type
:type type: str
:param columns: The index columns
:type columns: list or str
:param index: The index name
:type index: str
... | python | def _index_command(self, type, columns, index):
"""
Add a new index command to the blueprint.
:param type: The index type
:type type: str
:param columns: The index columns
:type columns: list or str
:param index: The index name
:type index: str
... | [
"def",
"_index_command",
"(",
"self",
",",
"type",
",",
"columns",
",",
"index",
")",
":",
"if",
"not",
"isinstance",
"(",
"columns",
",",
"list",
")",
":",
"columns",
"=",
"[",
"columns",
"]",
"if",
"not",
"index",
":",
"index",
"=",
"self",
".",
... | Add a new index command to the blueprint.
:param type: The index type
:type type: str
:param columns: The index columns
:type columns: list or str
:param index: The index name
:type index: str
:rtype: Fluent | [
"Add",
"a",
"new",
"index",
"command",
"to",
"the",
"blueprint",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L670-L691 | train |
sdispater/orator | orator/schema/blueprint.py | Blueprint._remove_column | def _remove_column(self, name):
"""
Removes a column from the blueprint.
:param name: The column name
:type name: str
:rtype: Blueprint
"""
self._columns = filter(lambda c: c.name != name, self._columns)
return self | python | def _remove_column(self, name):
"""
Removes a column from the blueprint.
:param name: The column name
:type name: str
:rtype: Blueprint
"""
self._columns = filter(lambda c: c.name != name, self._columns)
return self | [
"def",
"_remove_column",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"_columns",
"=",
"filter",
"(",
"lambda",
"c",
":",
"c",
".",
"name",
"!=",
"name",
",",
"self",
".",
"_columns",
")",
"return",
"self"
] | Removes a column from the blueprint.
:param name: The column name
:type name: str
:rtype: Blueprint | [
"Removes",
"a",
"column",
"from",
"the",
"blueprint",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L727-L738 | train |
sdispater/orator | orator/schema/blueprint.py | Blueprint._add_command | def _add_command(self, name, **parameters):
"""
Add a new command to the blueprint.
:param name: The command name
:type name: str
:param parameters: The command parameters
:type parameters: dict
:rtype: Fluent
"""
command = self._create_command(... | python | def _add_command(self, name, **parameters):
"""
Add a new command to the blueprint.
:param name: The command name
:type name: str
:param parameters: The command parameters
:type parameters: dict
:rtype: Fluent
"""
command = self._create_command(... | [
"def",
"_add_command",
"(",
"self",
",",
"name",
",",
"**",
"parameters",
")",
":",
"command",
"=",
"self",
".",
"_create_command",
"(",
"name",
",",
"**",
"parameters",
")",
"self",
".",
"_commands",
".",
"append",
"(",
"command",
")",
"return",
"comman... | Add a new command to the blueprint.
:param name: The command name
:type name: str
:param parameters: The command parameters
:type parameters: dict
:rtype: Fluent | [
"Add",
"a",
"new",
"command",
"to",
"the",
"blueprint",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L740-L755 | train |
sdispater/orator | orator/dbal/index.py | Index.get_quoted_columns | def get_quoted_columns(self, platform):
"""
Returns the quoted representation of the column names
the constraint is associated with.
But only if they were defined with one or a column name
is a keyword reserved by the platform.
Otherwise the plain unquoted value as inser... | python | def get_quoted_columns(self, platform):
"""
Returns the quoted representation of the column names
the constraint is associated with.
But only if they were defined with one or a column name
is a keyword reserved by the platform.
Otherwise the plain unquoted value as inser... | [
"def",
"get_quoted_columns",
"(",
"self",
",",
"platform",
")",
":",
"columns",
"=",
"[",
"]",
"for",
"column",
"in",
"self",
".",
"_columns",
".",
"values",
"(",
")",
":",
"columns",
".",
"append",
"(",
"column",
".",
"get_quoted_name",
"(",
"platform",... | Returns the quoted representation of the column names
the constraint is associated with.
But only if they were defined with one or a column name
is a keyword reserved by the platform.
Otherwise the plain unquoted value as inserted is returned.
:param platform: The platform to u... | [
"Returns",
"the",
"quoted",
"representation",
"of",
"the",
"column",
"names",
"the",
"constraint",
"is",
"associated",
"with",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/index.py#L65-L84 | train |
sdispater/orator | orator/dbal/index.py | Index.spans_columns | def spans_columns(self, column_names):
"""
Checks if this index exactly spans the given column names in the correct order.
:type column_names: list
:rtype: bool
"""
columns = self.get_columns()
number_of_columns = len(columns)
same_columns = True
... | python | def spans_columns(self, column_names):
"""
Checks if this index exactly spans the given column names in the correct order.
:type column_names: list
:rtype: bool
"""
columns = self.get_columns()
number_of_columns = len(columns)
same_columns = True
... | [
"def",
"spans_columns",
"(",
"self",
",",
"column_names",
")",
":",
"columns",
"=",
"self",
".",
"get_columns",
"(",
")",
"number_of_columns",
"=",
"len",
"(",
"columns",
")",
"same_columns",
"=",
"True",
"for",
"i",
"in",
"range",
"(",
"number_of_columns",
... | Checks if this index exactly spans the given column names in the correct order.
:type column_names: list
:rtype: bool | [
"Checks",
"if",
"this",
"index",
"exactly",
"spans",
"the",
"given",
"column",
"names",
"in",
"the",
"correct",
"order",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/index.py#L115-L134 | train |
sdispater/orator | orator/dbal/index.py | Index.is_fullfilled_by | def is_fullfilled_by(self, other):
"""
Checks if the other index already fulfills
all the indexing and constraint needs of the current one.
:param other: The other index
:type other: Index
:rtype: bool
"""
# allow the other index to be equally large only... | python | def is_fullfilled_by(self, other):
"""
Checks if the other index already fulfills
all the indexing and constraint needs of the current one.
:param other: The other index
:type other: Index
:rtype: bool
"""
# allow the other index to be equally large only... | [
"def",
"is_fullfilled_by",
"(",
"self",
",",
"other",
")",
":",
"if",
"len",
"(",
"other",
".",
"get_columns",
"(",
")",
")",
"!=",
"len",
"(",
"self",
".",
"get_columns",
"(",
")",
")",
":",
"return",
"False",
"if",
"not",
"self",
".",
"spans_column... | Checks if the other index already fulfills
all the indexing and constraint needs of the current one.
:param other: The other index
:type other: Index
:rtype: bool | [
"Checks",
"if",
"the",
"other",
"index",
"already",
"fulfills",
"all",
"the",
"indexing",
"and",
"constraint",
"needs",
"of",
"the",
"current",
"one",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/index.py#L136-L172 | train |
sdispater/orator | orator/dbal/index.py | Index.same_partial_index | def same_partial_index(self, other):
"""
Return whether the two indexes have the same partial index
:param other: The other index
:type other: Index
:rtype: bool
"""
if (
self.has_option("where")
and other.has_option("where")
... | python | def same_partial_index(self, other):
"""
Return whether the two indexes have the same partial index
:param other: The other index
:type other: Index
:rtype: bool
"""
if (
self.has_option("where")
and other.has_option("where")
... | [
"def",
"same_partial_index",
"(",
"self",
",",
"other",
")",
":",
"if",
"(",
"self",
".",
"has_option",
"(",
"\"where\"",
")",
"and",
"other",
".",
"has_option",
"(",
"\"where\"",
")",
"and",
"self",
".",
"get_option",
"(",
"\"where\"",
")",
"==",
"other... | Return whether the two indexes have the same partial index
:param other: The other index
:type other: Index
:rtype: bool | [
"Return",
"whether",
"the",
"two",
"indexes",
"have",
"the",
"same",
"partial",
"index"
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/index.py#L174-L193 | train |
sdispater/orator | orator/dbal/index.py | Index.overrules | def overrules(self, other):
"""
Detects if the other index is a non-unique, non primary index
that can be overwritten by this one.
:param other: The other index
:type other: Index
:rtype: bool
"""
if other.is_primary():
return False
e... | python | def overrules(self, other):
"""
Detects if the other index is a non-unique, non primary index
that can be overwritten by this one.
:param other: The other index
:type other: Index
:rtype: bool
"""
if other.is_primary():
return False
e... | [
"def",
"overrules",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
".",
"is_primary",
"(",
")",
":",
"return",
"False",
"elif",
"self",
".",
"is_simple_index",
"(",
")",
"and",
"other",
".",
"is_unique",
"(",
")",
":",
"return",
"False",
"same_col... | Detects if the other index is a non-unique, non primary index
that can be overwritten by this one.
:param other: The other index
:type other: Index
:rtype: bool | [
"Detects",
"if",
"the",
"other",
"index",
"is",
"a",
"non",
"-",
"unique",
"non",
"primary",
"index",
"that",
"can",
"be",
"overwritten",
"by",
"this",
"one",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/index.py#L195-L218 | train |
sdispater/orator | orator/dbal/index.py | Index.remove_flag | def remove_flag(self, flag):
"""
Removes a flag.
:type flag: str
"""
if self.has_flag(flag):
del self._flags[flag.lower()] | python | def remove_flag(self, flag):
"""
Removes a flag.
:type flag: str
"""
if self.has_flag(flag):
del self._flags[flag.lower()] | [
"def",
"remove_flag",
"(",
"self",
",",
"flag",
")",
":",
"if",
"self",
".",
"has_flag",
"(",
"flag",
")",
":",
"del",
"self",
".",
"_flags",
"[",
"flag",
".",
"lower",
"(",
")",
"]"
] | Removes a flag.
:type flag: str | [
"Removes",
"a",
"flag",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/index.py#L252-L259 | train |
sdispater/orator | orator/schema/grammars/mysql_grammar.py | MySQLSchemaGrammar._compile_create_encoding | def _compile_create_encoding(self, sql, connection, blueprint):
"""
Append the character set specifications to a command.
:type sql: str
:type connection: orator.connections.Connection
:type blueprint: Blueprint
:rtype: str
"""
charset = blueprint.charse... | python | def _compile_create_encoding(self, sql, connection, blueprint):
"""
Append the character set specifications to a command.
:type sql: str
:type connection: orator.connections.Connection
:type blueprint: Blueprint
:rtype: str
"""
charset = blueprint.charse... | [
"def",
"_compile_create_encoding",
"(",
"self",
",",
"sql",
",",
"connection",
",",
"blueprint",
")",
":",
"charset",
"=",
"blueprint",
".",
"charset",
"or",
"connection",
".",
"get_config",
"(",
"\"charset\"",
")",
"if",
"charset",
":",
"sql",
"+=",
"\" DEF... | Append the character set specifications to a command.
:type sql: str
:type connection: orator.connections.Connection
:type blueprint: Blueprint
:rtype: str | [
"Append",
"the",
"character",
"set",
"specifications",
"to",
"a",
"command",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/grammars/mysql_grammar.py#L71-L89 | train |
sdispater/orator | orator/commands/seeds/seed_command.py | SeedCommand._get_path | def _get_path(self, name):
"""
Get the destination class path.
:param name: The name
:type name: str
:rtype: str
"""
path = self.option("path")
if path is None:
path = self._get_seeders_path()
return os.path.join(path, "%s.py" % name... | python | def _get_path(self, name):
"""
Get the destination class path.
:param name: The name
:type name: str
:rtype: str
"""
path = self.option("path")
if path is None:
path = self._get_seeders_path()
return os.path.join(path, "%s.py" % name... | [
"def",
"_get_path",
"(",
"self",
",",
"name",
")",
":",
"path",
"=",
"self",
".",
"option",
"(",
"\"path\"",
")",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"self",
".",
"_get_seeders_path",
"(",
")",
"return",
"os",
".",
"path",
".",
"join",
"(... | Get the destination class path.
:param name: The name
:type name: str
:rtype: str | [
"Get",
"the",
"destination",
"class",
"path",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/commands/seeds/seed_command.py#L63-L76 | train |
sdispater/orator | orator/orm/relations/has_one_or_many.py | HasOneOrMany.update | def update(self, _attributes=None, **attributes):
"""
Perform an update on all the related models.
:param attributes: The attributes
:type attributes: dict
:rtype: int
"""
if _attributes is not None:
attributes.update(_attributes)
if self._r... | python | def update(self, _attributes=None, **attributes):
"""
Perform an update on all the related models.
:param attributes: The attributes
:type attributes: dict
:rtype: int
"""
if _attributes is not None:
attributes.update(_attributes)
if self._r... | [
"def",
"update",
"(",
"self",
",",
"_attributes",
"=",
"None",
",",
"**",
"attributes",
")",
":",
"if",
"_attributes",
"is",
"not",
"None",
":",
"attributes",
".",
"update",
"(",
"_attributes",
")",
"if",
"self",
".",
"_related",
".",
"uses_timestamps",
... | Perform an update on all the related models.
:param attributes: The attributes
:type attributes: dict
:rtype: int | [
"Perform",
"an",
"update",
"on",
"all",
"the",
"related",
"models",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/has_one_or_many.py#L297-L312 | train |
sdispater/orator | orator/utils/url.py | URL.get_dialect | def get_dialect(self):
"""Return the SQLAlchemy database dialect class corresponding
to this URL's driver name.
"""
if "+" not in self.drivername:
name = self.drivername
else:
name = self.drivername.replace("+", ".")
cls = registry.load(name)
... | python | def get_dialect(self):
"""Return the SQLAlchemy database dialect class corresponding
to this URL's driver name.
"""
if "+" not in self.drivername:
name = self.drivername
else:
name = self.drivername.replace("+", ".")
cls = registry.load(name)
... | [
"def",
"get_dialect",
"(",
"self",
")",
":",
"if",
"\"+\"",
"not",
"in",
"self",
".",
"drivername",
":",
"name",
"=",
"self",
".",
"drivername",
"else",
":",
"name",
"=",
"self",
".",
"drivername",
".",
"replace",
"(",
"\"+\"",
",",
"\".\"",
")",
"cl... | Return the SQLAlchemy database dialect class corresponding
to this URL's driver name. | [
"Return",
"the",
"SQLAlchemy",
"database",
"dialect",
"class",
"corresponding",
"to",
"this",
"URL",
"s",
"driver",
"name",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/utils/url.py#L122-L142 | train |
sdispater/orator | orator/utils/url.py | URL.translate_connect_args | def translate_connect_args(self, names=[], **kw):
"""Translate url attributes into a dictionary of connection arguments.
Returns attributes of this url (`host`, `database`, `username`,
`password`, `port`) as a plain dictionary. The attribute names are
used as the keys by default. Unse... | python | def translate_connect_args(self, names=[], **kw):
"""Translate url attributes into a dictionary of connection arguments.
Returns attributes of this url (`host`, `database`, `username`,
`password`, `port`) as a plain dictionary. The attribute names are
used as the keys by default. Unse... | [
"def",
"translate_connect_args",
"(",
"self",
",",
"names",
"=",
"[",
"]",
",",
"**",
"kw",
")",
":",
"translated",
"=",
"{",
"}",
"attribute_names",
"=",
"[",
"\"host\"",
",",
"\"database\"",
",",
"\"username\"",
",",
"\"password\"",
",",
"\"port\"",
"]",... | Translate url attributes into a dictionary of connection arguments.
Returns attributes of this url (`host`, `database`, `username`,
`password`, `port`) as a plain dictionary. The attribute names are
used as the keys by default. Unset or false attributes are omitted
from the final dict... | [
"Translate",
"url",
"attributes",
"into",
"a",
"dictionary",
"of",
"connection",
"arguments",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/utils/url.py#L144-L169 | train |
sdispater/orator | orator/dbal/platforms/platform.py | Platform.get_check_declaration_sql | def get_check_declaration_sql(self, definition):
"""
Obtains DBMS specific SQL code portion needed to set a CHECK constraint
declaration to be used in statements like CREATE TABLE.
:param definition: The check definition
:type definition: dict
:return: DBMS specific SQL... | python | def get_check_declaration_sql(self, definition):
"""
Obtains DBMS specific SQL code portion needed to set a CHECK constraint
declaration to be used in statements like CREATE TABLE.
:param definition: The check definition
:type definition: dict
:return: DBMS specific SQL... | [
"def",
"get_check_declaration_sql",
"(",
"self",
",",
"definition",
")",
":",
"constraints",
"=",
"[",
"]",
"for",
"field",
",",
"def_",
"in",
"definition",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"def_",
",",
"basestring",
")",
":",
"const... | Obtains DBMS specific SQL code portion needed to set a CHECK constraint
declaration to be used in statements like CREATE TABLE.
:param definition: The check definition
:type definition: dict
:return: DBMS specific SQL code portion needed to set a CHECK constraint.
:rtype: str | [
"Obtains",
"DBMS",
"specific",
"SQL",
"code",
"portion",
"needed",
"to",
"set",
"a",
"CHECK",
"constraint",
"declaration",
"to",
"be",
"used",
"in",
"statements",
"like",
"CREATE",
"TABLE",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L71-L93 | train |
sdispater/orator | orator/dbal/platforms/platform.py | Platform.get_unique_constraint_declaration_sql | def get_unique_constraint_declaration_sql(self, name, index):
"""
Obtains DBMS specific SQL code portion needed to set a unique
constraint declaration to be used in statements like CREATE TABLE.
:param name: The name of the unique constraint.
:type name: str
:param inde... | python | def get_unique_constraint_declaration_sql(self, name, index):
"""
Obtains DBMS specific SQL code portion needed to set a unique
constraint declaration to be used in statements like CREATE TABLE.
:param name: The name of the unique constraint.
:type name: str
:param inde... | [
"def",
"get_unique_constraint_declaration_sql",
"(",
"self",
",",
"name",
",",
"index",
")",
":",
"columns",
"=",
"index",
".",
"get_quoted_columns",
"(",
"self",
")",
"name",
"=",
"Identifier",
"(",
"name",
")",
"if",
"not",
"columns",
":",
"raise",
"DBALEx... | Obtains DBMS specific SQL code portion needed to set a unique
constraint declaration to be used in statements like CREATE TABLE.
:param name: The name of the unique constraint.
:type name: str
:param index: The index definition
:type index: Index
:return: DBMS specific... | [
"Obtains",
"DBMS",
"specific",
"SQL",
"code",
"portion",
"needed",
"to",
"set",
"a",
"unique",
"constraint",
"declaration",
"to",
"be",
"used",
"in",
"statements",
"like",
"CREATE",
"TABLE",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L95-L119 | train |
sdispater/orator | orator/dbal/platforms/platform.py | Platform.get_foreign_key_declaration_sql | def get_foreign_key_declaration_sql(self, foreign_key):
"""
Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint
of a field declaration to be used in statements like CREATE TABLE.
:param foreign_key: The foreign key
:type foreign_key: ForeignKeyConstrai... | python | def get_foreign_key_declaration_sql(self, foreign_key):
"""
Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint
of a field declaration to be used in statements like CREATE TABLE.
:param foreign_key: The foreign key
:type foreign_key: ForeignKeyConstrai... | [
"def",
"get_foreign_key_declaration_sql",
"(",
"self",
",",
"foreign_key",
")",
":",
"sql",
"=",
"self",
".",
"get_foreign_key_base_declaration_sql",
"(",
"foreign_key",
")",
"sql",
"+=",
"self",
".",
"get_advanced_foreign_key_options_sql",
"(",
"foreign_key",
")",
"r... | Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint
of a field declaration to be used in statements like CREATE TABLE.
:param foreign_key: The foreign key
:type foreign_key: ForeignKeyConstraint
:rtype: str | [
"Obtain",
"DBMS",
"specific",
"SQL",
"code",
"portion",
"needed",
"to",
"set",
"the",
"FOREIGN",
"KEY",
"constraint",
"of",
"a",
"field",
"declaration",
"to",
"be",
"used",
"in",
"statements",
"like",
"CREATE",
"TABLE",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L148-L161 | train |
sdispater/orator | orator/dbal/platforms/platform.py | Platform.get_advanced_foreign_key_options_sql | def get_advanced_foreign_key_options_sql(self, foreign_key):
"""
Returns the FOREIGN KEY query section dealing with non-standard options
as MATCH, INITIALLY DEFERRED, ON UPDATE, ...
:param foreign_key: The foreign key
:type foreign_key: ForeignKeyConstraint
:rtype: str
... | python | def get_advanced_foreign_key_options_sql(self, foreign_key):
"""
Returns the FOREIGN KEY query section dealing with non-standard options
as MATCH, INITIALLY DEFERRED, ON UPDATE, ...
:param foreign_key: The foreign key
:type foreign_key: ForeignKeyConstraint
:rtype: str
... | [
"def",
"get_advanced_foreign_key_options_sql",
"(",
"self",
",",
"foreign_key",
")",
":",
"query",
"=",
"\"\"",
"if",
"self",
".",
"supports_foreign_key_on_update",
"(",
")",
"and",
"foreign_key",
".",
"has_option",
"(",
"\"on_update\"",
")",
":",
"query",
"+=",
... | Returns the FOREIGN KEY query section dealing with non-standard options
as MATCH, INITIALLY DEFERRED, ON UPDATE, ...
:param foreign_key: The foreign key
:type foreign_key: ForeignKeyConstraint
:rtype: str | [
"Returns",
"the",
"FOREIGN",
"KEY",
"query",
"section",
"dealing",
"with",
"non",
"-",
"standard",
"options",
"as",
"MATCH",
"INITIALLY",
"DEFERRED",
"ON",
"UPDATE",
"..."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L163-L186 | train |
sdispater/orator | orator/dbal/platforms/platform.py | Platform.get_foreign_key_referential_action_sql | def get_foreign_key_referential_action_sql(self, action):
"""
Returns the given referential action in uppercase if valid, otherwise throws an exception.
:param action: The action
:type action: str
:rtype: str
"""
action = action.upper()
if action not in ... | python | def get_foreign_key_referential_action_sql(self, action):
"""
Returns the given referential action in uppercase if valid, otherwise throws an exception.
:param action: The action
:type action: str
:rtype: str
"""
action = action.upper()
if action not in ... | [
"def",
"get_foreign_key_referential_action_sql",
"(",
"self",
",",
"action",
")",
":",
"action",
"=",
"action",
".",
"upper",
"(",
")",
"if",
"action",
"not",
"in",
"[",
"\"CASCADE\"",
",",
"\"SET NULL\"",
",",
"\"NO ACTION\"",
",",
"\"RESTRICT\"",
",",
"\"SET... | Returns the given referential action in uppercase if valid, otherwise throws an exception.
:param action: The action
:type action: str
:rtype: str | [
"Returns",
"the",
"given",
"referential",
"action",
"in",
"uppercase",
"if",
"valid",
"otherwise",
"throws",
"an",
"exception",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L188-L207 | train |
sdispater/orator | orator/dbal/platforms/platform.py | Platform.get_foreign_key_base_declaration_sql | def get_foreign_key_base_declaration_sql(self, foreign_key):
"""
Obtains DBMS specific SQL code portion needed to set the FOREIGN KEY constraint
of a field declaration to be used in statements like CREATE TABLE.
:param foreign_key: The foreign key
:type foreign_key: ForeignKeyCo... | python | def get_foreign_key_base_declaration_sql(self, foreign_key):
"""
Obtains DBMS specific SQL code portion needed to set the FOREIGN KEY constraint
of a field declaration to be used in statements like CREATE TABLE.
:param foreign_key: The foreign key
:type foreign_key: ForeignKeyCo... | [
"def",
"get_foreign_key_base_declaration_sql",
"(",
"self",
",",
"foreign_key",
")",
":",
"sql",
"=",
"\"\"",
"if",
"foreign_key",
".",
"get_name",
"(",
")",
":",
"sql",
"+=",
"\"CONSTRAINT %s \"",
"%",
"foreign_key",
".",
"get_quoted_name",
"(",
"self",
")",
... | Obtains DBMS specific SQL code portion needed to set the FOREIGN KEY constraint
of a field declaration to be used in statements like CREATE TABLE.
:param foreign_key: The foreign key
:type foreign_key: ForeignKeyConstraint
:rtype: str | [
"Obtains",
"DBMS",
"specific",
"SQL",
"code",
"portion",
"needed",
"to",
"set",
"the",
"FOREIGN",
"KEY",
"constraint",
"of",
"a",
"field",
"declaration",
"to",
"be",
"used",
"in",
"statements",
"like",
"CREATE",
"TABLE",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L209-L240 | train |
sdispater/orator | orator/dbal/platforms/platform.py | Platform.get_column_declaration_list_sql | def get_column_declaration_list_sql(self, fields):
"""
Gets declaration of a number of fields in bulk.
"""
query_fields = []
for name, field in fields.items():
query_fields.append(self.get_column_declaration_sql(name, field))
return ", ".join(query_fields) | python | def get_column_declaration_list_sql(self, fields):
"""
Gets declaration of a number of fields in bulk.
"""
query_fields = []
for name, field in fields.items():
query_fields.append(self.get_column_declaration_sql(name, field))
return ", ".join(query_fields) | [
"def",
"get_column_declaration_list_sql",
"(",
"self",
",",
"fields",
")",
":",
"query_fields",
"=",
"[",
"]",
"for",
"name",
",",
"field",
"in",
"fields",
".",
"items",
"(",
")",
":",
"query_fields",
".",
"append",
"(",
"self",
".",
"get_column_declaration_... | Gets declaration of a number of fields in bulk. | [
"Gets",
"declaration",
"of",
"a",
"number",
"of",
"fields",
"in",
"bulk",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L256-L265 | train |
sdispater/orator | orator/dbal/platforms/platform.py | Platform.get_create_index_sql | def get_create_index_sql(self, index, table):
"""
Returns the SQL to create an index on a table on this platform.
:param index: The index
:type index: Index
:param table: The table
:type table: Table or str
:rtype: str
"""
if isinstance(table, T... | python | def get_create_index_sql(self, index, table):
"""
Returns the SQL to create an index on a table on this platform.
:param index: The index
:type index: Index
:param table: The table
:type table: Table or str
:rtype: str
"""
if isinstance(table, T... | [
"def",
"get_create_index_sql",
"(",
"self",
",",
"index",
",",
"table",
")",
":",
"if",
"isinstance",
"(",
"table",
",",
"Table",
")",
":",
"table",
"=",
"table",
".",
"get_quoted_name",
"(",
"self",
")",
"name",
"=",
"index",
".",
"get_quoted_name",
"("... | Returns the SQL to create an index on a table on this platform.
:param index: The index
:type index: Index
:param table: The table
:type table: Table or str
:rtype: str | [
"Returns",
"the",
"SQL",
"to",
"create",
"an",
"index",
"on",
"a",
"table",
"on",
"this",
"platform",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L418-L452 | train |
sdispater/orator | orator/dbal/platforms/platform.py | Platform.get_create_primary_key_sql | def get_create_primary_key_sql(self, index, table):
"""
Returns the SQL to create an unnamed primary key constraint.
:param index: The index
:type index: Index
:param table: The table
:type table: Table or str
:rtype: str
"""
return "ALTER TABLE... | python | def get_create_primary_key_sql(self, index, table):
"""
Returns the SQL to create an unnamed primary key constraint.
:param index: The index
:type index: Index
:param table: The table
:type table: Table or str
:rtype: str
"""
return "ALTER TABLE... | [
"def",
"get_create_primary_key_sql",
"(",
"self",
",",
"index",
",",
"table",
")",
":",
"return",
"\"ALTER TABLE %s ADD PRIMARY KEY (%s)\"",
"%",
"(",
"table",
",",
"self",
".",
"get_index_field_declaration_list_sql",
"(",
"index",
".",
"get_quoted_columns",
"(",
"sel... | Returns the SQL to create an unnamed primary key constraint.
:param index: The index
:type index: Index
:param table: The table
:type table: Table or str
:rtype: str | [
"Returns",
"the",
"SQL",
"to",
"create",
"an",
"unnamed",
"primary",
"key",
"constraint",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L482-L497 | train |
sdispater/orator | orator/dbal/platforms/platform.py | Platform.get_create_foreign_key_sql | def get_create_foreign_key_sql(self, foreign_key, table):
"""
Returns the SQL to create a new foreign key.
:rtype: sql
"""
if isinstance(table, Table):
table = table.get_quoted_name(self)
query = "ALTER TABLE %s ADD %s" % (
table,
sel... | python | def get_create_foreign_key_sql(self, foreign_key, table):
"""
Returns the SQL to create a new foreign key.
:rtype: sql
"""
if isinstance(table, Table):
table = table.get_quoted_name(self)
query = "ALTER TABLE %s ADD %s" % (
table,
sel... | [
"def",
"get_create_foreign_key_sql",
"(",
"self",
",",
"foreign_key",
",",
"table",
")",
":",
"if",
"isinstance",
"(",
"table",
",",
"Table",
")",
":",
"table",
"=",
"table",
".",
"get_quoted_name",
"(",
"self",
")",
"query",
"=",
"\"ALTER TABLE %s ADD %s\"",
... | Returns the SQL to create a new foreign key.
:rtype: sql | [
"Returns",
"the",
"SQL",
"to",
"create",
"a",
"new",
"foreign",
"key",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L499-L513 | train |
sdispater/orator | orator/dbal/platforms/platform.py | Platform.get_drop_table_sql | def get_drop_table_sql(self, table):
"""
Returns the SQL snippet to drop an existing table.
:param table: The table
:type table: Table or str
:rtype: str
"""
if isinstance(table, Table):
table = table.get_quoted_name(self)
return "DROP TABLE... | python | def get_drop_table_sql(self, table):
"""
Returns the SQL snippet to drop an existing table.
:param table: The table
:type table: Table or str
:rtype: str
"""
if isinstance(table, Table):
table = table.get_quoted_name(self)
return "DROP TABLE... | [
"def",
"get_drop_table_sql",
"(",
"self",
",",
"table",
")",
":",
"if",
"isinstance",
"(",
"table",
",",
"Table",
")",
":",
"table",
"=",
"table",
".",
"get_quoted_name",
"(",
"self",
")",
"return",
"\"DROP TABLE %s\"",
"%",
"table"
] | Returns the SQL snippet to drop an existing table.
:param table: The table
:type table: Table or str
:rtype: str | [
"Returns",
"the",
"SQL",
"snippet",
"to",
"drop",
"an",
"existing",
"table",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L515-L527 | train |
sdispater/orator | orator/dbal/platforms/platform.py | Platform.get_drop_index_sql | def get_drop_index_sql(self, index, table=None):
"""
Returns the SQL to drop an index from a table.
:param index: The index
:type index: Index or str
:param table: The table
:type table: Table or str or None
:rtype: str
"""
if isinstance(index, ... | python | def get_drop_index_sql(self, index, table=None):
"""
Returns the SQL to drop an index from a table.
:param index: The index
:type index: Index or str
:param table: The table
:type table: Table or str or None
:rtype: str
"""
if isinstance(index, ... | [
"def",
"get_drop_index_sql",
"(",
"self",
",",
"index",
",",
"table",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"index",
",",
"Index",
")",
":",
"index",
"=",
"index",
".",
"get_quoted_name",
"(",
"self",
")",
"return",
"\"DROP INDEX %s\"",
"%",
"i... | Returns the SQL to drop an index from a table.
:param index: The index
:type index: Index or str
:param table: The table
:type table: Table or str or None
:rtype: str | [
"Returns",
"the",
"SQL",
"to",
"drop",
"an",
"index",
"from",
"a",
"table",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L529-L544 | train |
sdispater/orator | orator/dbal/platforms/platform.py | Platform._get_create_table_sql | def _get_create_table_sql(self, table_name, columns, options=None):
"""
Returns the SQL used to create a table.
:param table_name: The name of the table to create
:type table_name: str
:param columns: The table columns
:type columns: dict
:param options: The op... | python | def _get_create_table_sql(self, table_name, columns, options=None):
"""
Returns the SQL used to create a table.
:param table_name: The name of the table to create
:type table_name: str
:param columns: The table columns
:type columns: dict
:param options: The op... | [
"def",
"_get_create_table_sql",
"(",
"self",
",",
"table_name",
",",
"columns",
",",
"options",
"=",
"None",
")",
":",
"options",
"=",
"options",
"or",
"{",
"}",
"column_list_sql",
"=",
"self",
".",
"get_column_declaration_list_sql",
"(",
"columns",
")",
"if",... | Returns the SQL used to create a table.
:param table_name: The name of the table to create
:type table_name: str
:param columns: The table columns
:type columns: dict
:param options: The options
:type options: dict
:rtype: str | [
"Returns",
"the",
"SQL",
"used",
"to",
"create",
"a",
"table",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L605-L653 | train |
sdispater/orator | orator/dbal/platforms/platform.py | Platform.quote_identifier | def quote_identifier(self, string):
"""
Quotes a string so that it can be safely used as a table or column name,
even if it is a reserved word of the platform. This also detects identifier
chains separated by dot and quotes them independently.
:param string: The identifier name ... | python | def quote_identifier(self, string):
"""
Quotes a string so that it can be safely used as a table or column name,
even if it is a reserved word of the platform. This also detects identifier
chains separated by dot and quotes them independently.
:param string: The identifier name ... | [
"def",
"quote_identifier",
"(",
"self",
",",
"string",
")",
":",
"if",
"\".\"",
"in",
"string",
":",
"parts",
"=",
"list",
"(",
"map",
"(",
"self",
".",
"quote_single_identifier",
",",
"string",
".",
"split",
"(",
"\".\"",
")",
")",
")",
"return",
"\".... | Quotes a string so that it can be safely used as a table or column name,
even if it is a reserved word of the platform. This also detects identifier
chains separated by dot and quotes them independently.
:param string: The identifier name to be quoted.
:type string: str
:return... | [
"Quotes",
"a",
"string",
"so",
"that",
"it",
"can",
"be",
"safely",
"used",
"as",
"a",
"table",
"or",
"column",
"name",
"even",
"if",
"it",
"is",
"a",
"reserved",
"word",
"of",
"the",
"platform",
".",
"This",
"also",
"detects",
"identifier",
"chains",
... | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L655-L672 | train |
sdispater/orator | orator/connectors/connector.py | Connector._detect_database_platform | def _detect_database_platform(self):
"""
Detects and sets the database platform.
Evaluates custom platform class and version in order to set the correct platform.
:raises InvalidPlatformSpecified: if an invalid platform was specified for this connection.
"""
version = s... | python | def _detect_database_platform(self):
"""
Detects and sets the database platform.
Evaluates custom platform class and version in order to set the correct platform.
:raises InvalidPlatformSpecified: if an invalid platform was specified for this connection.
"""
version = s... | [
"def",
"_detect_database_platform",
"(",
"self",
")",
":",
"version",
"=",
"self",
".",
"_get_database_platform_version",
"(",
")",
"if",
"version",
"is",
"not",
"None",
":",
"self",
".",
"_platform",
"=",
"self",
".",
"_create_database_platform_for_version",
"(",... | Detects and sets the database platform.
Evaluates custom platform class and version in order to set the correct platform.
:raises InvalidPlatformSpecified: if an invalid platform was specified for this connection. | [
"Detects",
"and",
"sets",
"the",
"database",
"platform",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/connectors/connector.py#L65-L78 | train |
sdispater/orator | orator/pagination/paginator.py | Paginator._check_for_more_pages | def _check_for_more_pages(self):
"""
Check for more pages. The last item will be sliced off.
"""
self._has_more = len(self._items) > self.per_page
self._items = self._items[0 : self.per_page] | python | def _check_for_more_pages(self):
"""
Check for more pages. The last item will be sliced off.
"""
self._has_more = len(self._items) > self.per_page
self._items = self._items[0 : self.per_page] | [
"def",
"_check_for_more_pages",
"(",
"self",
")",
":",
"self",
".",
"_has_more",
"=",
"len",
"(",
"self",
".",
"_items",
")",
">",
"self",
".",
"per_page",
"self",
".",
"_items",
"=",
"self",
".",
"_items",
"[",
"0",
":",
"self",
".",
"per_page",
"]"... | Check for more pages. The last item will be sliced off. | [
"Check",
"for",
"more",
"pages",
".",
"The",
"last",
"item",
"will",
"be",
"sliced",
"off",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/pagination/paginator.py#L55-L61 | train |
sdispater/orator | orator/dbal/comparator.py | Comparator.diff_index | def diff_index(self, index1, index2):
"""
Finds the difference between the indexes index1 and index2.
Compares index1 with index2 and returns True if there are any
differences or False in case there are no differences.
:type index1: Index
:type index2: Index
:r... | python | def diff_index(self, index1, index2):
"""
Finds the difference between the indexes index1 and index2.
Compares index1 with index2 and returns True if there are any
differences or False in case there are no differences.
:type index1: Index
:type index2: Index
:r... | [
"def",
"diff_index",
"(",
"self",
",",
"index1",
",",
"index2",
")",
":",
"if",
"index1",
".",
"is_fullfilled_by",
"(",
"index2",
")",
"and",
"index2",
".",
"is_fullfilled_by",
"(",
"index1",
")",
":",
"return",
"False",
"return",
"True"
] | Finds the difference between the indexes index1 and index2.
Compares index1 with index2 and returns True if there are any
differences or False in case there are no differences.
:type index1: Index
:type index2: Index
:rtype: bool | [
"Finds",
"the",
"difference",
"between",
"the",
"indexes",
"index1",
"and",
"index2",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/comparator.py#L285-L300 | train |
sdispater/orator | orator/seeds/seeder.py | Seeder.call | def call(self, klass):
"""
Seed the given connection from the given class.
:param klass: The Seeder class
:type klass: class
"""
self._resolve(klass).run()
if self._command:
self._command.line("<info>Seeded:</info> <fg=cyan>%s</>" % klass.__name__) | python | def call(self, klass):
"""
Seed the given connection from the given class.
:param klass: The Seeder class
:type klass: class
"""
self._resolve(klass).run()
if self._command:
self._command.line("<info>Seeded:</info> <fg=cyan>%s</>" % klass.__name__) | [
"def",
"call",
"(",
"self",
",",
"klass",
")",
":",
"self",
".",
"_resolve",
"(",
"klass",
")",
".",
"run",
"(",
")",
"if",
"self",
".",
"_command",
":",
"self",
".",
"_command",
".",
"line",
"(",
"\"<info>Seeded:</info> <fg=cyan>%s</>\"",
"%",
"klass",
... | Seed the given connection from the given class.
:param klass: The Seeder class
:type klass: class | [
"Seed",
"the",
"given",
"connection",
"from",
"the",
"given",
"class",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/seeds/seeder.py#L25-L35 | train |
sdispater/orator | orator/seeds/seeder.py | Seeder._resolve | def _resolve(self, klass):
"""
Resolve an instance of the given seeder klass.
:param klass: The Seeder class
:type klass: class
"""
resolver = None
if self._resolver:
resolver = self._resolver
elif self._command:
resolver = self._... | python | def _resolve(self, klass):
"""
Resolve an instance of the given seeder klass.
:param klass: The Seeder class
:type klass: class
"""
resolver = None
if self._resolver:
resolver = self._resolver
elif self._command:
resolver = self._... | [
"def",
"_resolve",
"(",
"self",
",",
"klass",
")",
":",
"resolver",
"=",
"None",
"if",
"self",
".",
"_resolver",
":",
"resolver",
"=",
"self",
".",
"_resolver",
"elif",
"self",
".",
"_command",
":",
"resolver",
"=",
"self",
".",
"_command",
".",
"resol... | Resolve an instance of the given seeder klass.
:param klass: The Seeder class
:type klass: class | [
"Resolve",
"an",
"instance",
"of",
"the",
"given",
"seeder",
"klass",
"."
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/seeds/seeder.py#L37-L57 | train |
sdispater/orator | orator/query/builder.py | QueryBuilder.select | def select(self, *columns):
"""
Set the columns to be selected
:param columns: The columns to be selected
:type columns: tuple
:return: The current QueryBuilder instance
:rtype: QueryBuilder
"""
if not columns:
columns = ["*"]
self.c... | python | def select(self, *columns):
"""
Set the columns to be selected
:param columns: The columns to be selected
:type columns: tuple
:return: The current QueryBuilder instance
:rtype: QueryBuilder
"""
if not columns:
columns = ["*"]
self.c... | [
"def",
"select",
"(",
"self",
",",
"*",
"columns",
")",
":",
"if",
"not",
"columns",
":",
"columns",
"=",
"[",
"\"*\"",
"]",
"self",
".",
"columns",
"=",
"list",
"(",
"columns",
")",
"return",
"self"
] | Set the columns to be selected
:param columns: The columns to be selected
:type columns: tuple
:return: The current QueryBuilder instance
:rtype: QueryBuilder | [
"Set",
"the",
"columns",
"to",
"be",
"selected"
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L90-L105 | train |
sdispater/orator | orator/query/builder.py | QueryBuilder.select_raw | def select_raw(self, expression, bindings=None):
"""
Add a new raw select expression to the query
:param expression: The raw expression
:type expression: str
:param bindings: The expression bindings
:type bindings: list
:return: The current QueryBuilder instanc... | python | def select_raw(self, expression, bindings=None):
"""
Add a new raw select expression to the query
:param expression: The raw expression
:type expression: str
:param bindings: The expression bindings
:type bindings: list
:return: The current QueryBuilder instanc... | [
"def",
"select_raw",
"(",
"self",
",",
"expression",
",",
"bindings",
"=",
"None",
")",
":",
"self",
".",
"add_select",
"(",
"QueryExpression",
"(",
"expression",
")",
")",
"if",
"bindings",
":",
"self",
".",
"add_binding",
"(",
"bindings",
",",
"\"select\... | Add a new raw select expression to the query
:param expression: The raw expression
:type expression: str
:param bindings: The expression bindings
:type bindings: list
:return: The current QueryBuilder instance
:rtype: QueryBuilder | [
"Add",
"a",
"new",
"raw",
"select",
"expression",
"to",
"the",
"query"
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L107-L125 | train |
sdispater/orator | orator/query/builder.py | QueryBuilder.select_sub | def select_sub(self, query, as_):
"""
Add a subselect expression to the query
:param query: A QueryBuilder instance
:type query: QueryBuilder
:param as_: The subselect alias
:type as_: str
:return: The current QueryBuilder instance
:rtype: QueryBuilder
... | python | def select_sub(self, query, as_):
"""
Add a subselect expression to the query
:param query: A QueryBuilder instance
:type query: QueryBuilder
:param as_: The subselect alias
:type as_: str
:return: The current QueryBuilder instance
:rtype: QueryBuilder
... | [
"def",
"select_sub",
"(",
"self",
",",
"query",
",",
"as_",
")",
":",
"if",
"isinstance",
"(",
"query",
",",
"QueryBuilder",
")",
":",
"bindings",
"=",
"query",
".",
"get_bindings",
"(",
")",
"query",
"=",
"query",
".",
"to_sql",
"(",
")",
"elif",
"i... | Add a subselect expression to the query
:param query: A QueryBuilder instance
:type query: QueryBuilder
:param as_: The subselect alias
:type as_: str
:return: The current QueryBuilder instance
:rtype: QueryBuilder | [
"Add",
"a",
"subselect",
"expression",
"to",
"the",
"query"
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L127-L151 | train |
sdispater/orator | orator/query/builder.py | QueryBuilder.add_select | def add_select(self, *column):
"""
Add a new select column to query
:param column: The column to add
:type column: str
:return: The current QueryBuilder instance
:rtype: QueryBuilder
"""
if not column:
column = []
self.columns += lis... | python | def add_select(self, *column):
"""
Add a new select column to query
:param column: The column to add
:type column: str
:return: The current QueryBuilder instance
:rtype: QueryBuilder
"""
if not column:
column = []
self.columns += lis... | [
"def",
"add_select",
"(",
"self",
",",
"*",
"column",
")",
":",
"if",
"not",
"column",
":",
"column",
"=",
"[",
"]",
"self",
".",
"columns",
"+=",
"list",
"(",
"column",
")",
"return",
"self"
] | Add a new select column to query
:param column: The column to add
:type column: str
:return: The current QueryBuilder instance
:rtype: QueryBuilder | [
"Add",
"a",
"new",
"select",
"column",
"to",
"query"
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L153-L168 | train |
sdispater/orator | orator/query/builder.py | QueryBuilder.left_join_where | def left_join_where(self, table, one, operator, two):
"""
Add a "left join where" clause to the query
:param table: The table to join with, can also be a JoinClause instance
:type table: str or JoinClause
:param one: The first column of the join condition
:type one: str... | python | def left_join_where(self, table, one, operator, two):
"""
Add a "left join where" clause to the query
:param table: The table to join with, can also be a JoinClause instance
:type table: str or JoinClause
:param one: The first column of the join condition
:type one: str... | [
"def",
"left_join_where",
"(",
"self",
",",
"table",
",",
"one",
",",
"operator",
",",
"two",
")",
":",
"return",
"self",
".",
"join_where",
"(",
"table",
",",
"one",
",",
"operator",
",",
"two",
",",
"\"left\"",
")"
] | Add a "left join where" clause to the query
:param table: The table to join with, can also be a JoinClause instance
:type table: str or JoinClause
:param one: The first column of the join condition
:type one: str
:param operator: The operator of the join condition
:typ... | [
"Add",
"a",
"left",
"join",
"where",
"clause",
"to",
"the",
"query"
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L280-L299 | train |
sdispater/orator | orator/query/builder.py | QueryBuilder.right_join | def right_join(self, table, one=None, operator=None, two=None):
"""
Add a right join to the query
:param table: The table to join with, can also be a JoinClause instance
:type table: str or JoinClause
:param one: The first column of the join condition
:type one: str
... | python | def right_join(self, table, one=None, operator=None, two=None):
"""
Add a right join to the query
:param table: The table to join with, can also be a JoinClause instance
:type table: str or JoinClause
:param one: The first column of the join condition
:type one: str
... | [
"def",
"right_join",
"(",
"self",
",",
"table",
",",
"one",
"=",
"None",
",",
"operator",
"=",
"None",
",",
"two",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"table",
",",
"JoinClause",
")",
":",
"table",
".",
"type",
"=",
"\"right\"",
"return",... | Add a right join to the query
:param table: The table to join with, can also be a JoinClause instance
:type table: str or JoinClause
:param one: The first column of the join condition
:type one: str
:param operator: The operator of the join condition
:type operator: st... | [
"Add",
"a",
"right",
"join",
"to",
"the",
"query"
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L301-L323 | train |
sdispater/orator | orator/query/builder.py | QueryBuilder.right_join_where | def right_join_where(self, table, one, operator, two):
"""
Add a "right join where" clause to the query
:param table: The table to join with, can also be a JoinClause instance
:type table: str or JoinClause
:param one: The first column of the join condition
:type one: s... | python | def right_join_where(self, table, one, operator, two):
"""
Add a "right join where" clause to the query
:param table: The table to join with, can also be a JoinClause instance
:type table: str or JoinClause
:param one: The first column of the join condition
:type one: s... | [
"def",
"right_join_where",
"(",
"self",
",",
"table",
",",
"one",
",",
"operator",
",",
"two",
")",
":",
"return",
"self",
".",
"join_where",
"(",
"table",
",",
"one",
",",
"operator",
",",
"two",
",",
"\"right\"",
")"
] | Add a "right join where" clause to the query
:param table: The table to join with, can also be a JoinClause instance
:type table: str or JoinClause
:param one: The first column of the join condition
:type one: str
:param operator: The operator of the join condition
:ty... | [
"Add",
"a",
"right",
"join",
"where",
"clause",
"to",
"the",
"query"
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L325-L344 | train |
sdispater/orator | orator/query/builder.py | QueryBuilder.group_by | def group_by(self, *columns):
"""
Add a "group by" clause to the query
:param columns: The columns to group by
:type columns: tuple
:return: The current QueryBuilder instance
:rtype: QueryBuilder
"""
for column in columns:
self.groups.append(... | python | def group_by(self, *columns):
"""
Add a "group by" clause to the query
:param columns: The columns to group by
:type columns: tuple
:return: The current QueryBuilder instance
:rtype: QueryBuilder
"""
for column in columns:
self.groups.append(... | [
"def",
"group_by",
"(",
"self",
",",
"*",
"columns",
")",
":",
"for",
"column",
"in",
"columns",
":",
"self",
".",
"groups",
".",
"append",
"(",
"column",
")",
"return",
"self"
] | Add a "group by" clause to the query
:param columns: The columns to group by
:type columns: tuple
:return: The current QueryBuilder instance
:rtype: QueryBuilder | [
"Add",
"a",
"group",
"by",
"clause",
"to",
"the",
"query"
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L694-L707 | train |
sdispater/orator | orator/query/builder.py | QueryBuilder.having_raw | def having_raw(self, sql, bindings=None, boolean="and"):
"""
Add a raw having clause to the query
:param sql: The raw query
:type sql: str
:param bindings: The query bindings
:type bindings: list
:param boolean: Boolean joiner type
:type boolean: str
... | python | def having_raw(self, sql, bindings=None, boolean="and"):
"""
Add a raw having clause to the query
:param sql: The raw query
:type sql: str
:param bindings: The query bindings
:type bindings: list
:param boolean: Boolean joiner type
:type boolean: str
... | [
"def",
"having_raw",
"(",
"self",
",",
"sql",
",",
"bindings",
"=",
"None",
",",
"boolean",
"=",
"\"and\"",
")",
":",
"type",
"=",
"\"raw\"",
"self",
".",
"havings",
".",
"append",
"(",
"{",
"\"type\"",
":",
"type",
",",
"\"sql\"",
":",
"sql",
",",
... | Add a raw having clause to the query
:param sql: The raw query
:type sql: str
:param bindings: The query bindings
:type bindings: list
:param boolean: Boolean joiner type
:type boolean: str
:return: The current QueryBuilder instance
:rtype: QueryBuilde... | [
"Add",
"a",
"raw",
"having",
"clause",
"to",
"the",
"query"
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L763-L785 | train |
sdispater/orator | orator/query/builder.py | QueryBuilder.order_by | def order_by(self, column, direction="asc"):
"""
Add a "order by" clause to the query
:param column: The order by column
:type column: str
:param direction: The direction of the order
:type direction: str
:return: The current QueryBuilder instance
:rtyp... | python | def order_by(self, column, direction="asc"):
"""
Add a "order by" clause to the query
:param column: The order by column
:type column: str
:param direction: The direction of the order
:type direction: str
:return: The current QueryBuilder instance
:rtyp... | [
"def",
"order_by",
"(",
"self",
",",
"column",
",",
"direction",
"=",
"\"asc\"",
")",
":",
"if",
"self",
".",
"unions",
":",
"prop",
"=",
"\"union_orders\"",
"else",
":",
"prop",
"=",
"\"orders\"",
"if",
"direction",
".",
"lower",
"(",
")",
"==",
"\"as... | Add a "order by" clause to the query
:param column: The order by column
:type column: str
:param direction: The direction of the order
:type direction: str
:return: The current QueryBuilder instance
:rtype: QueryBuilder | [
"Add",
"a",
"order",
"by",
"clause",
"to",
"the",
"query"
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L802-L827 | train |
sdispater/orator | orator/query/builder.py | QueryBuilder.order_by_raw | def order_by_raw(self, sql, bindings=None):
"""
Add a raw "order by" clause to the query
:param sql: The raw clause
:type sql: str
:param bindings: The bdings
:param bindings: list
:return: The current QueryBuilder instance
:rtype: QueryBuilder
... | python | def order_by_raw(self, sql, bindings=None):
"""
Add a raw "order by" clause to the query
:param sql: The raw clause
:type sql: str
:param bindings: The bdings
:param bindings: list
:return: The current QueryBuilder instance
:rtype: QueryBuilder
... | [
"def",
"order_by_raw",
"(",
"self",
",",
"sql",
",",
"bindings",
"=",
"None",
")",
":",
"if",
"bindings",
"is",
"None",
":",
"bindings",
"=",
"[",
"]",
"type",
"=",
"\"raw\"",
"self",
".",
"orders",
".",
"append",
"(",
"{",
"\"type\"",
":",
"type",
... | Add a raw "order by" clause to the query
:param sql: The raw clause
:type sql: str
:param bindings: The bdings
:param bindings: list
:return: The current QueryBuilder instance
:rtype: QueryBuilder | [
"Add",
"a",
"raw",
"order",
"by",
"clause",
"to",
"the",
"query"
] | bd90bf198ee897751848f9a92e49d18e60a74136 | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L855-L877 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.