Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
SimpleTests.test_simple | (self) |
The main test here is that the all the models can be created without
any database errors. We can also do some more simple insertion and
lookup tests whilst we're here to show that the second of models do
refer to the tables from the first set.
|
The main test here is that the all the models can be created without
any database errors. We can also do some more simple insertion and
lookup tests whilst we're here to show that the second of models do
refer to the tables from the first set.
| def test_simple(self):
"""
The main test here is that the all the models can be created without
any database errors. We can also do some more simple insertion and
lookup tests whilst we're here to show that the second of models do
refer to the tables from the first set.
"... | [
"def",
"test_simple",
"(",
"self",
")",
":",
"# Insert some data into one set of models.",
"a",
"=",
"A01",
".",
"objects",
".",
"create",
"(",
"f_a",
"=",
"\"foo\"",
",",
"f_b",
"=",
"42",
")",
"B01",
".",
"objects",
".",
"create",
"(",
"fk_a",
"=",
"a"... | [
10,
4
] | [
41,
47
] | python | en | ['en', 'error', 'th'] | False |
ManyToManyUnmanagedTests.test_many_to_many_between_unmanaged | (self) |
The intermediary table between two unmanaged models should not be created.
|
The intermediary table between two unmanaged models should not be created.
| def test_many_to_many_between_unmanaged(self):
"""
The intermediary table between two unmanaged models should not be created.
"""
table = Unmanaged2._meta.get_field('mm').m2m_db_table()
tables = connection.introspection.table_names()
self.assertTrue(table not in tables, "... | [
"def",
"test_many_to_many_between_unmanaged",
"(",
"self",
")",
":",
"table",
"=",
"Unmanaged2",
".",
"_meta",
".",
"get_field",
"(",
"'mm'",
")",
".",
"m2m_db_table",
"(",
")",
"tables",
"=",
"connection",
".",
"introspection",
".",
"table_names",
"(",
")",
... | [
46,
4
] | [
52,
97
] | python | en | ['en', 'error', 'th'] | False |
ManyToManyUnmanagedTests.test_many_to_many_between_unmanaged_and_managed | (self) |
An intermediary table between a managed and an unmanaged model should be created.
|
An intermediary table between a managed and an unmanaged model should be created.
| def test_many_to_many_between_unmanaged_and_managed(self):
"""
An intermediary table between a managed and an unmanaged model should be created.
"""
table = Managed1._meta.get_field('mm').m2m_db_table()
tables = connection.introspection.table_names()
self.assertTrue(table... | [
"def",
"test_many_to_many_between_unmanaged_and_managed",
"(",
"self",
")",
":",
"table",
"=",
"Managed1",
".",
"_meta",
".",
"get_field",
"(",
"'mm'",
")",
".",
"m2m_db_table",
"(",
")",
"tables",
"=",
"connection",
".",
"introspection",
".",
"table_names",
"("... | [
54,
4
] | [
60,
78
] | python | en | ['en', 'error', 'th'] | False |
UniversalDetector.reset | (self) |
Reset the UniversalDetector and all of its probers back to their
initial states. This is called by ``__init__``, so you only need to
call this directly in between analyses of different documents.
|
Reset the UniversalDetector and all of its probers back to their
initial states. This is called by ``__init__``, so you only need to
call this directly in between analyses of different documents.
| def reset(self):
"""
Reset the UniversalDetector and all of its probers back to their
initial states. This is called by ``__init__``, so you only need to
call this directly in between analyses of different documents.
"""
self.result = {'encoding': None, 'confidence': 0.0... | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"result",
"=",
"{",
"'encoding'",
":",
"None",
",",
"'confidence'",
":",
"0.0",
",",
"'language'",
":",
"None",
"}",
"self",
".",
"done",
"=",
"False",
"self",
".",
"_got_data",
"=",
"False",
"self"... | [
93,
4
] | [
108,
26
] | python | en | ['en', 'error', 'th'] | False |
UniversalDetector.feed | (self, byte_str) |
Takes a chunk of a document and feeds it through all of the relevant
charset probers.
After calling ``feed``, you can check the value of the ``done``
attribute to see if you need to continue feeding the
``UniversalDetector`` more data, or if it has made a prediction
(in... |
Takes a chunk of a document and feeds it through all of the relevant
charset probers. | def feed(self, byte_str):
"""
Takes a chunk of a document and feeds it through all of the relevant
charset probers.
After calling ``feed``, you can check the value of the ``done``
attribute to see if you need to continue feeding the
``UniversalDetector`` more data, or if... | [
"def",
"feed",
"(",
"self",
",",
"byte_str",
")",
":",
"if",
"self",
".",
"done",
":",
"return",
"if",
"not",
"len",
"(",
"byte_str",
")",
":",
"return",
"if",
"not",
"isinstance",
"(",
"byte_str",
",",
"bytearray",
")",
":",
"byte_str",
"=",
"bytear... | [
110,
4
] | [
217,
42
] | python | en | ['en', 'error', 'th'] | False |
UniversalDetector.close | (self) |
Stop analyzing the current document and come up with a final
prediction.
:returns: The ``result`` attribute, a ``dict`` with the keys
`encoding`, `confidence`, and `language`.
|
Stop analyzing the current document and come up with a final
prediction. | def close(self):
"""
Stop analyzing the current document and come up with a final
prediction.
:returns: The ``result`` attribute, a ``dict`` with the keys
`encoding`, `confidence`, and `language`.
"""
# Don't bother with checks if we're already done
... | [
"def",
"close",
"(",
"self",
")",
":",
"# Don't bother with checks if we're already done",
"if",
"self",
".",
"done",
":",
"return",
"self",
".",
"result",
"self",
".",
"done",
"=",
"True",
"if",
"not",
"self",
".",
"_got_data",
":",
"self",
".",
"logger",
... | [
219,
4
] | [
285,
26
] | python | en | ['en', 'error', 'th'] | False |
MigrationExecutor.migration_plan | (self, targets, clean_start=False) |
Given a set of targets, return a list of (Migration instance, backwards?).
|
Given a set of targets, return a list of (Migration instance, backwards?).
| def migration_plan(self, targets, clean_start=False):
"""
Given a set of targets, return a list of (Migration instance, backwards?).
"""
plan = []
if clean_start:
applied = {}
else:
applied = dict(self.loader.applied_migrations)
for target ... | [
"def",
"migration_plan",
"(",
"self",
",",
"targets",
",",
"clean_start",
"=",
"False",
")",
":",
"plan",
"=",
"[",
"]",
"if",
"clean_start",
":",
"applied",
"=",
"{",
"}",
"else",
":",
"applied",
"=",
"dict",
"(",
"self",
".",
"loader",
".",
"applie... | [
21,
4
] | [
61,
19
] | python | en | ['en', 'error', 'th'] | False |
MigrationExecutor._create_project_state | (self, with_applied_migrations=False) |
Create a project state including all the applications without
migrations and applied migrations if with_applied_migrations=True.
|
Create a project state including all the applications without
migrations and applied migrations if with_applied_migrations=True.
| def _create_project_state(self, with_applied_migrations=False):
"""
Create a project state including all the applications without
migrations and applied migrations if with_applied_migrations=True.
"""
state = ProjectState(real_apps=list(self.loader.unmigrated_apps))
if wi... | [
"def",
"_create_project_state",
"(",
"self",
",",
"with_applied_migrations",
"=",
"False",
")",
":",
"state",
"=",
"ProjectState",
"(",
"real_apps",
"=",
"list",
"(",
"self",
".",
"loader",
".",
"unmigrated_apps",
")",
")",
"if",
"with_applied_migrations",
":",
... | [
63,
4
] | [
79,
20
] | python | en | ['en', 'error', 'th'] | False |
MigrationExecutor.migrate | (self, targets, plan=None, state=None, fake=False, fake_initial=False) |
Migrate the database up to the given targets.
Django first needs to create all project states before a migration is
(un)applied and in a second step run all the database operations.
|
Migrate the database up to the given targets. | def migrate(self, targets, plan=None, state=None, fake=False, fake_initial=False):
"""
Migrate the database up to the given targets.
Django first needs to create all project states before a migration is
(un)applied and in a second step run all the database operations.
"""
... | [
"def",
"migrate",
"(",
"self",
",",
"targets",
",",
"plan",
"=",
"None",
",",
"state",
"=",
"None",
",",
"fake",
"=",
"False",
",",
"fake_initial",
"=",
"False",
")",
":",
"# The django_migrations table must be present to record applied",
"# migrations.",
"self",
... | [
81,
4
] | [
124,
20
] | python | en | ['en', 'error', 'th'] | False |
MigrationExecutor._migrate_all_forwards | (self, state, plan, full_plan, fake, fake_initial) |
Take a list of 2-tuples of the form (migration instance, False) and
apply them in the order they occur in the full_plan.
|
Take a list of 2-tuples of the form (migration instance, False) and
apply them in the order they occur in the full_plan.
| def _migrate_all_forwards(self, state, plan, full_plan, fake, fake_initial):
"""
Take a list of 2-tuples of the form (migration instance, False) and
apply them in the order they occur in the full_plan.
"""
migrations_to_run = {m[0] for m in plan}
for migration, _ in full_... | [
"def",
"_migrate_all_forwards",
"(",
"self",
",",
"state",
",",
"plan",
",",
"full_plan",
",",
"fake",
",",
"fake_initial",
")",
":",
"migrations_to_run",
"=",
"{",
"m",
"[",
"0",
"]",
"for",
"m",
"in",
"plan",
"}",
"for",
"migration",
",",
"_",
"in",
... | [
126,
4
] | [
149,
20
] | python | en | ['en', 'error', 'th'] | False |
MigrationExecutor._migrate_all_backwards | (self, plan, full_plan, fake) |
Take a list of 2-tuples of the form (migration instance, True) and
unapply them in reverse order they occur in the full_plan.
Since unapplying a migration requires the project state prior to that
migration, Django will compute the migration states before each of them
in a first... |
Take a list of 2-tuples of the form (migration instance, True) and
unapply them in reverse order they occur in the full_plan. | def _migrate_all_backwards(self, plan, full_plan, fake):
"""
Take a list of 2-tuples of the form (migration instance, True) and
unapply them in reverse order they occur in the full_plan.
Since unapplying a migration requires the project state prior to that
migration, Django will... | [
"def",
"_migrate_all_backwards",
"(",
"self",
",",
"plan",
",",
"full_plan",
",",
"fake",
")",
":",
"migrations_to_run",
"=",
"{",
"m",
"[",
"0",
"]",
"for",
"m",
"in",
"plan",
"}",
"# Holds all migration states prior to the migrations being unapplied",
"states",
... | [
151,
4
] | [
210,
20
] | python | en | ['en', 'error', 'th'] | False |
MigrationExecutor.collect_sql | (self, plan) |
Take a migration plan and return a list of collected SQL statements
that represent the best-efforts version of that plan.
|
Take a migration plan and return a list of collected SQL statements
that represent the best-efforts version of that plan.
| def collect_sql(self, plan):
"""
Take a migration plan and return a list of collected SQL statements
that represent the best-efforts version of that plan.
"""
statements = []
state = None
for migration, backwards in plan:
with self.connection.schema_ed... | [
"def",
"collect_sql",
"(",
"self",
",",
"plan",
")",
":",
"statements",
"=",
"[",
"]",
"state",
"=",
"None",
"for",
"migration",
",",
"backwards",
"in",
"plan",
":",
"with",
"self",
".",
"connection",
".",
"schema_editor",
"(",
"collect_sql",
"=",
"True"... | [
212,
4
] | [
228,
25
] | python | en | ['en', 'error', 'th'] | False |
MigrationExecutor.apply_migration | (self, state, migration, fake=False, fake_initial=False) | Run a migration forwards. | Run a migration forwards. | def apply_migration(self, state, migration, fake=False, fake_initial=False):
"""Run a migration forwards."""
migration_recorded = False
if self.progress_callback:
self.progress_callback("apply_start", migration, fake)
if not fake:
if fake_initial:
... | [
"def",
"apply_migration",
"(",
"self",
",",
"state",
",",
"migration",
",",
"fake",
"=",
"False",
",",
"fake_initial",
"=",
"False",
")",
":",
"migration_recorded",
"=",
"False",
"if",
"self",
".",
"progress_callback",
":",
"self",
".",
"progress_callback",
... | [
230,
4
] | [
252,
20
] | python | en | ['es', 'en', 'en'] | True |
MigrationExecutor.unapply_migration | (self, state, migration, fake=False) | Run a migration backwards. | Run a migration backwards. | def unapply_migration(self, state, migration, fake=False):
"""Run a migration backwards."""
if self.progress_callback:
self.progress_callback("unapply_start", migration, fake)
if not fake:
with self.connection.schema_editor(atomic=migration.atomic) as schema_editor:
... | [
"def",
"unapply_migration",
"(",
"self",
",",
"state",
",",
"migration",
",",
"fake",
"=",
"False",
")",
":",
"if",
"self",
".",
"progress_callback",
":",
"self",
".",
"progress_callback",
"(",
"\"unapply_start\"",
",",
"migration",
",",
"fake",
")",
"if",
... | [
262,
4
] | [
278,
20
] | python | en | ['it', 'fil', 'en'] | False |
MigrationExecutor.check_replacements | (self) |
Mark replacement migrations applied if their replaced set all are.
Do this unconditionally on every migrate, rather than just when
migrations are applied or unapplied, to correctly handle the case
when a new squash migration is pushed to a deployment that already had
all its re... |
Mark replacement migrations applied if their replaced set all are. | def check_replacements(self):
"""
Mark replacement migrations applied if their replaced set all are.
Do this unconditionally on every migrate, rather than just when
migrations are applied or unapplied, to correctly handle the case
when a new squash migration is pushed to a deplo... | [
"def",
"check_replacements",
"(",
"self",
")",
":",
"applied",
"=",
"self",
".",
"recorder",
".",
"applied_migrations",
"(",
")",
"for",
"key",
",",
"migration",
"in",
"self",
".",
"loader",
".",
"replacements",
".",
"items",
"(",
")",
":",
"all_applied",
... | [
280,
4
] | [
295,
50
] | python | en | ['en', 'error', 'th'] | False |
MigrationExecutor.detect_soft_applied | (self, project_state, migration) |
Test whether a migration has been implicitly applied - that the
tables or columns it would create exist. This is intended only for use
on initial migrations (as it only looks for CreateModel and AddField).
|
Test whether a migration has been implicitly applied - that the
tables or columns it would create exist. This is intended only for use
on initial migrations (as it only looks for CreateModel and AddField).
| def detect_soft_applied(self, project_state, migration):
"""
Test whether a migration has been implicitly applied - that the
tables or columns it would create exist. This is intended only for use
on initial migrations (as it only looks for CreateModel and AddField).
"""
d... | [
"def",
"detect_soft_applied",
"(",
"self",
",",
"project_state",
",",
"migration",
")",
":",
"def",
"should_skip_detecting_model",
"(",
"migration",
",",
"model",
")",
":",
"\"\"\"\n No need to detect tables for proxy models, unmanaged models, or\n models th... | [
297,
4
] | [
375,
87
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.autoinc_sql | (self, table, column) |
Return any SQL needed to support auto-incrementing primary keys, or
None if no SQL is necessary.
This SQL is executed when a table is created.
|
Return any SQL needed to support auto-incrementing primary keys, or
None if no SQL is necessary. | def autoinc_sql(self, table, column):
"""
Return any SQL needed to support auto-incrementing primary keys, or
None if no SQL is necessary.
This SQL is executed when a table is created.
"""
return None | [
"def",
"autoinc_sql",
"(",
"self",
",",
"table",
",",
"column",
")",
":",
"return",
"None"
] | [
58,
4
] | [
65,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.bulk_batch_size | (self, fields, objs) |
Return the maximum allowed batch size for the backend. The fields
are the fields going to be inserted in the batch, the objs contains
all the objects to be inserted.
|
Return the maximum allowed batch size for the backend. The fields
are the fields going to be inserted in the batch, the objs contains
all the objects to be inserted.
| def bulk_batch_size(self, fields, objs):
"""
Return the maximum allowed batch size for the backend. The fields
are the fields going to be inserted in the batch, the objs contains
all the objects to be inserted.
"""
return len(objs) | [
"def",
"bulk_batch_size",
"(",
"self",
",",
"fields",
",",
"objs",
")",
":",
"return",
"len",
"(",
"objs",
")"
] | [
67,
4
] | [
73,
24
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.cache_key_culling_sql | (self) |
Return an SQL query that retrieves the first cache key greater than the
n smallest.
This is used by the 'db' cache backend to determine where to start
culling.
|
Return an SQL query that retrieves the first cache key greater than the
n smallest. | def cache_key_culling_sql(self):
"""
Return an SQL query that retrieves the first cache key greater than the
n smallest.
This is used by the 'db' cache backend to determine where to start
culling.
"""
return "SELECT cache_key FROM %s ORDER BY cache_key LIMIT 1 OF... | [
"def",
"cache_key_culling_sql",
"(",
"self",
")",
":",
"return",
"\"SELECT cache_key FROM %s ORDER BY cache_key LIMIT 1 OFFSET %%s\""
] | [
75,
4
] | [
83,
79
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.unification_cast_sql | (self, output_field) |
Given a field instance, return the SQL that casts the result of a union
to that type. The resulting string should contain a '%s' placeholder
for the expression being cast.
|
Given a field instance, return the SQL that casts the result of a union
to that type. The resulting string should contain a '%s' placeholder
for the expression being cast.
| def unification_cast_sql(self, output_field):
"""
Given a field instance, return the SQL that casts the result of a union
to that type. The resulting string should contain a '%s' placeholder
for the expression being cast.
"""
return '%s' | [
"def",
"unification_cast_sql",
"(",
"self",
",",
"output_field",
")",
":",
"return",
"'%s'"
] | [
85,
4
] | [
91,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.date_extract_sql | (self, lookup_type, field_name) |
Given a lookup_type of 'year', 'month', or 'day', return the SQL that
extracts a value from the given date field field_name.
|
Given a lookup_type of 'year', 'month', or 'day', return the SQL that
extracts a value from the given date field field_name.
| def date_extract_sql(self, lookup_type, field_name):
"""
Given a lookup_type of 'year', 'month', or 'day', return the SQL that
extracts a value from the given date field field_name.
"""
raise NotImplementedError('subclasses of BaseDatabaseOperations may require a date_extract_sql... | [
"def",
"date_extract_sql",
"(",
"self",
",",
"lookup_type",
",",
"field_name",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a date_extract_sql() method'",
")"
] | [
93,
4
] | [
98,
113
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.date_interval_sql | (self, timedelta) |
Implement the date interval functionality for expressions.
|
Implement the date interval functionality for expressions.
| def date_interval_sql(self, timedelta):
"""
Implement the date interval functionality for expressions.
"""
raise NotImplementedError('subclasses of BaseDatabaseOperations may require a date_interval_sql() method') | [
"def",
"date_interval_sql",
"(",
"self",
",",
"timedelta",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a date_interval_sql() method'",
")"
] | [
100,
4
] | [
104,
114
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.date_trunc_sql | (self, lookup_type, field_name) |
Given a lookup_type of 'year', 'month', or 'day', return the SQL that
truncates the given date field field_name to a date object with only
the given specificity.
|
Given a lookup_type of 'year', 'month', or 'day', return the SQL that
truncates the given date field field_name to a date object with only
the given specificity.
| def date_trunc_sql(self, lookup_type, field_name):
"""
Given a lookup_type of 'year', 'month', or 'day', return the SQL that
truncates the given date field field_name to a date object with only
the given specificity.
"""
raise NotImplementedError('subclasses of BaseDataba... | [
"def",
"date_trunc_sql",
"(",
"self",
",",
"lookup_type",
",",
"field_name",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a date_trunc_sql() method.'",
")"
] | [
106,
4
] | [
112,
112
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.datetime_cast_date_sql | (self, field_name, tzname) |
Return the SQL to cast a datetime value to date value.
|
Return the SQL to cast a datetime value to date value.
| def datetime_cast_date_sql(self, field_name, tzname):
"""
Return the SQL to cast a datetime value to date value.
"""
raise NotImplementedError(
'subclasses of BaseDatabaseOperations may require a '
'datetime_cast_date_sql() method.'
) | [
"def",
"datetime_cast_date_sql",
"(",
"self",
",",
"field_name",
",",
"tzname",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a '",
"'datetime_cast_date_sql() method.'",
")"
] | [
114,
4
] | [
121,
9
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.datetime_cast_time_sql | (self, field_name, tzname) |
Return the SQL to cast a datetime value to time value.
|
Return the SQL to cast a datetime value to time value.
| def datetime_cast_time_sql(self, field_name, tzname):
"""
Return the SQL to cast a datetime value to time value.
"""
raise NotImplementedError('subclasses of BaseDatabaseOperations may require a datetime_cast_time_sql() method') | [
"def",
"datetime_cast_time_sql",
"(",
"self",
",",
"field_name",
",",
"tzname",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a datetime_cast_time_sql() method'",
")"
] | [
123,
4
] | [
127,
119
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.datetime_extract_sql | (self, lookup_type, field_name, tzname) |
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute', or
'second', return the SQL that extracts a value from the given
datetime field field_name.
|
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute', or
'second', return the SQL that extracts a value from the given
datetime field field_name.
| def datetime_extract_sql(self, lookup_type, field_name, tzname):
"""
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute', or
'second', return the SQL that extracts a value from the given
datetime field field_name.
"""
raise NotImplementedError('subclasses of B... | [
"def",
"datetime_extract_sql",
"(",
"self",
",",
"lookup_type",
",",
"field_name",
",",
"tzname",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a datetime_extract_sql() method'",
")"
] | [
129,
4
] | [
135,
117
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.datetime_trunc_sql | (self, lookup_type, field_name, tzname) |
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute', or
'second', return the SQL that truncates the given datetime field
field_name to a datetime object with only the given specificity.
|
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute', or
'second', return the SQL that truncates the given datetime field
field_name to a datetime object with only the given specificity.
| def datetime_trunc_sql(self, lookup_type, field_name, tzname):
"""
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute', or
'second', return the SQL that truncates the given datetime field
field_name to a datetime object with only the given specificity.
"""
rai... | [
"def",
"datetime_trunc_sql",
"(",
"self",
",",
"lookup_type",
",",
"field_name",
",",
"tzname",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a datetime_trunc_sql() method'",
")"
] | [
137,
4
] | [
143,
115
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.time_trunc_sql | (self, lookup_type, field_name) |
Given a lookup_type of 'hour', 'minute' or 'second', return the SQL
that truncates the given time field field_name to a time object with
only the given specificity.
|
Given a lookup_type of 'hour', 'minute' or 'second', return the SQL
that truncates the given time field field_name to a time object with
only the given specificity.
| def time_trunc_sql(self, lookup_type, field_name):
"""
Given a lookup_type of 'hour', 'minute' or 'second', return the SQL
that truncates the given time field field_name to a time object with
only the given specificity.
"""
raise NotImplementedError('subclasses of BaseDat... | [
"def",
"time_trunc_sql",
"(",
"self",
",",
"lookup_type",
",",
"field_name",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a time_trunc_sql() method'",
")"
] | [
145,
4
] | [
151,
111
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.time_extract_sql | (self, lookup_type, field_name) |
Given a lookup_type of 'hour', 'minute', or 'second', return the SQL
that extracts a value from the given time field field_name.
|
Given a lookup_type of 'hour', 'minute', or 'second', return the SQL
that extracts a value from the given time field field_name.
| def time_extract_sql(self, lookup_type, field_name):
"""
Given a lookup_type of 'hour', 'minute', or 'second', return the SQL
that extracts a value from the given time field field_name.
"""
return self.date_extract_sql(lookup_type, field_name) | [
"def",
"time_extract_sql",
"(",
"self",
",",
"lookup_type",
",",
"field_name",
")",
":",
"return",
"self",
".",
"date_extract_sql",
"(",
"lookup_type",
",",
"field_name",
")"
] | [
153,
4
] | [
158,
61
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.deferrable_sql | (self) |
Return the SQL to make a constraint "initially deferred" during a
CREATE TABLE statement.
|
Return the SQL to make a constraint "initially deferred" during a
CREATE TABLE statement.
| def deferrable_sql(self):
"""
Return the SQL to make a constraint "initially deferred" during a
CREATE TABLE statement.
"""
return '' | [
"def",
"deferrable_sql",
"(",
"self",
")",
":",
"return",
"''"
] | [
160,
4
] | [
165,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.distinct_sql | (self, fields, params) |
Return an SQL DISTINCT clause which removes duplicate rows from the
result set. If any fields are given, only check the given fields for
duplicates.
|
Return an SQL DISTINCT clause which removes duplicate rows from the
result set. If any fields are given, only check the given fields for
duplicates.
| def distinct_sql(self, fields, params):
"""
Return an SQL DISTINCT clause which removes duplicate rows from the
result set. If any fields are given, only check the given fields for
duplicates.
"""
if fields:
raise NotSupportedError('DISTINCT ON fields is not s... | [
"def",
"distinct_sql",
"(",
"self",
",",
"fields",
",",
"params",
")",
":",
"if",
"fields",
":",
"raise",
"NotSupportedError",
"(",
"'DISTINCT ON fields is not supported by this database backend'",
")",
"else",
":",
"return",
"[",
"'DISTINCT'",
"]",
",",
"[",
"]"
... | [
167,
4
] | [
176,
35
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.fetch_returned_insert_columns | (self, cursor) |
Given a cursor object that has just performed an INSERT...RETURNING
statement into a table, return the newly created data.
|
Given a cursor object that has just performed an INSERT...RETURNING
statement into a table, return the newly created data.
| def fetch_returned_insert_columns(self, cursor):
"""
Given a cursor object that has just performed an INSERT...RETURNING
statement into a table, return the newly created data.
"""
return cursor.fetchone() | [
"def",
"fetch_returned_insert_columns",
"(",
"self",
",",
"cursor",
")",
":",
"return",
"cursor",
".",
"fetchone",
"(",
")"
] | [
178,
4
] | [
183,
32
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.field_cast_sql | (self, db_type, internal_type) |
Given a column type (e.g. 'BLOB', 'VARCHAR') and an internal type
(e.g. 'GenericIPAddressField'), return the SQL to cast it before using
it in a WHERE statement. The resulting string should contain a '%s'
placeholder for the column being searched against.
|
Given a column type (e.g. 'BLOB', 'VARCHAR') and an internal type
(e.g. 'GenericIPAddressField'), return the SQL to cast it before using
it in a WHERE statement. The resulting string should contain a '%s'
placeholder for the column being searched against.
| def field_cast_sql(self, db_type, internal_type):
"""
Given a column type (e.g. 'BLOB', 'VARCHAR') and an internal type
(e.g. 'GenericIPAddressField'), return the SQL to cast it before using
it in a WHERE statement. The resulting string should contain a '%s'
placeholder for the c... | [
"def",
"field_cast_sql",
"(",
"self",
",",
"db_type",
",",
"internal_type",
")",
":",
"return",
"'%s'"
] | [
185,
4
] | [
192,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.force_no_ordering | (self) |
Return a list used in the "ORDER BY" clause to force no ordering at
all. Return an empty list to include nothing in the ordering.
|
Return a list used in the "ORDER BY" clause to force no ordering at
all. Return an empty list to include nothing in the ordering.
| def force_no_ordering(self):
"""
Return a list used in the "ORDER BY" clause to force no ordering at
all. Return an empty list to include nothing in the ordering.
"""
return [] | [
"def",
"force_no_ordering",
"(",
"self",
")",
":",
"return",
"[",
"]"
] | [
194,
4
] | [
199,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.for_update_sql | (self, nowait=False, skip_locked=False, of=()) |
Return the FOR UPDATE SQL clause to lock rows for an update operation.
|
Return the FOR UPDATE SQL clause to lock rows for an update operation.
| def for_update_sql(self, nowait=False, skip_locked=False, of=()):
"""
Return the FOR UPDATE SQL clause to lock rows for an update operation.
"""
return 'FOR UPDATE%s%s%s' % (
' OF %s' % ', '.join(of) if of else '',
' NOWAIT' if nowait else '',
' SKIP L... | [
"def",
"for_update_sql",
"(",
"self",
",",
"nowait",
"=",
"False",
",",
"skip_locked",
"=",
"False",
",",
"of",
"=",
"(",
")",
")",
":",
"return",
"'FOR UPDATE%s%s%s'",
"%",
"(",
"' OF %s'",
"%",
"', '",
".",
"join",
"(",
"of",
")",
"if",
"of",
"else... | [
201,
4
] | [
209,
9
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.limit_offset_sql | (self, low_mark, high_mark) | Return LIMIT/OFFSET SQL clause. | Return LIMIT/OFFSET SQL clause. | def limit_offset_sql(self, low_mark, high_mark):
"""Return LIMIT/OFFSET SQL clause."""
limit, offset = self._get_limit_offset_params(low_mark, high_mark)
return ' '.join(sql for sql in (
('LIMIT %d' % limit) if limit else None,
('OFFSET %d' % offset) if offset else None,
... | [
"def",
"limit_offset_sql",
"(",
"self",
",",
"low_mark",
",",
"high_mark",
")",
":",
"limit",
",",
"offset",
"=",
"self",
".",
"_get_limit_offset_params",
"(",
"low_mark",
",",
"high_mark",
")",
"return",
"' '",
".",
"join",
"(",
"sql",
"for",
"sql",
"in",... | [
219,
4
] | [
225,
17
] | python | de | ['de', 'fr', 'en'] | False |
BaseDatabaseOperations.last_executed_query | (self, cursor, sql, params) |
Return a string of the query last executed by the given cursor, with
placeholders replaced with actual values.
`sql` is the raw query containing placeholders and `params` is the
sequence of parameters. These are used by default, but this method
exists for database backends to p... |
Return a string of the query last executed by the given cursor, with
placeholders replaced with actual values. | def last_executed_query(self, cursor, sql, params):
"""
Return a string of the query last executed by the given cursor, with
placeholders replaced with actual values.
`sql` is the raw query containing placeholders and `params` is the
sequence of parameters. These are used by def... | [
"def",
"last_executed_query",
"(",
"self",
",",
"cursor",
",",
"sql",
",",
"params",
")",
":",
"# Convert params to contain string values.",
"def",
"to_string",
"(",
"s",
")",
":",
"return",
"force_str",
"(",
"s",
",",
"strings_only",
"=",
"True",
",",
"errors... | [
227,
4
] | [
247,
59
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.last_insert_id | (self, cursor, table_name, pk_name) |
Given a cursor object that has just performed an INSERT statement into
a table that has an auto-incrementing ID, return the newly created ID.
`pk_name` is the name of the primary-key column.
|
Given a cursor object that has just performed an INSERT statement into
a table that has an auto-incrementing ID, return the newly created ID. | def last_insert_id(self, cursor, table_name, pk_name):
"""
Given a cursor object that has just performed an INSERT statement into
a table that has an auto-incrementing ID, return the newly created ID.
`pk_name` is the name of the primary-key column.
"""
return cursor.las... | [
"def",
"last_insert_id",
"(",
"self",
",",
"cursor",
",",
"table_name",
",",
"pk_name",
")",
":",
"return",
"cursor",
".",
"lastrowid"
] | [
249,
4
] | [
256,
31
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.lookup_cast | (self, lookup_type, internal_type=None) |
Return the string to use in a query when performing lookups
("contains", "like", etc.). It should contain a '%s' placeholder for
the column being searched against.
|
Return the string to use in a query when performing lookups
("contains", "like", etc.). It should contain a '%s' placeholder for
the column being searched against.
| def lookup_cast(self, lookup_type, internal_type=None):
"""
Return the string to use in a query when performing lookups
("contains", "like", etc.). It should contain a '%s' placeholder for
the column being searched against.
"""
return "%s" | [
"def",
"lookup_cast",
"(",
"self",
",",
"lookup_type",
",",
"internal_type",
"=",
"None",
")",
":",
"return",
"\"%s\""
] | [
258,
4
] | [
264,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.max_in_list_size | (self) |
Return the maximum number of items that can be passed in a single 'IN'
list condition, or None if the backend does not impose a limit.
|
Return the maximum number of items that can be passed in a single 'IN'
list condition, or None if the backend does not impose a limit.
| def max_in_list_size(self):
"""
Return the maximum number of items that can be passed in a single 'IN'
list condition, or None if the backend does not impose a limit.
"""
return None | [
"def",
"max_in_list_size",
"(",
"self",
")",
":",
"return",
"None"
] | [
266,
4
] | [
271,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.max_name_length | (self) |
Return the maximum length of table and column names, or None if there
is no limit.
|
Return the maximum length of table and column names, or None if there
is no limit.
| def max_name_length(self):
"""
Return the maximum length of table and column names, or None if there
is no limit.
"""
return None | [
"def",
"max_name_length",
"(",
"self",
")",
":",
"return",
"None"
] | [
273,
4
] | [
278,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.no_limit_value | (self) |
Return the value to use for the LIMIT when we are wanting "LIMIT
infinity". Return None if the limit clause can be omitted in this case.
|
Return the value to use for the LIMIT when we are wanting "LIMIT
infinity". Return None if the limit clause can be omitted in this case.
| def no_limit_value(self):
"""
Return the value to use for the LIMIT when we are wanting "LIMIT
infinity". Return None if the limit clause can be omitted in this case.
"""
raise NotImplementedError('subclasses of BaseDatabaseOperations may require a no_limit_value() method') | [
"def",
"no_limit_value",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a no_limit_value() method'",
")"
] | [
280,
4
] | [
285,
111
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.pk_default_value | (self) |
Return the value to use during an INSERT statement to specify that
the field should use its default value.
|
Return the value to use during an INSERT statement to specify that
the field should use its default value.
| def pk_default_value(self):
"""
Return the value to use during an INSERT statement to specify that
the field should use its default value.
"""
return 'DEFAULT' | [
"def",
"pk_default_value",
"(",
"self",
")",
":",
"return",
"'DEFAULT'"
] | [
287,
4
] | [
292,
24
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.prepare_sql_script | (self, sql) |
Take an SQL script that may contain multiple lines and return a list
of statements to feed to successive cursor.execute() calls.
Since few databases are able to process raw SQL scripts in a single
cursor.execute() call and PEP 249 doesn't talk about this use case,
the default i... |
Take an SQL script that may contain multiple lines and return a list
of statements to feed to successive cursor.execute() calls. | def prepare_sql_script(self, sql):
"""
Take an SQL script that may contain multiple lines and return a list
of statements to feed to successive cursor.execute() calls.
Since few databases are able to process raw SQL scripts in a single
cursor.execute() call and PEP 249 doesn't t... | [
"def",
"prepare_sql_script",
"(",
"self",
",",
"sql",
")",
":",
"return",
"[",
"sqlparse",
".",
"format",
"(",
"statement",
",",
"strip_comments",
"=",
"True",
")",
"for",
"statement",
"in",
"sqlparse",
".",
"split",
"(",
"sql",
")",
"if",
"statement",
"... | [
294,
4
] | [
306,
9
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.process_clob | (self, value) |
Return the value of a CLOB column, for backends that return a locator
object that requires additional processing.
|
Return the value of a CLOB column, for backends that return a locator
object that requires additional processing.
| def process_clob(self, value):
"""
Return the value of a CLOB column, for backends that return a locator
object that requires additional processing.
"""
return value | [
"def",
"process_clob",
"(",
"self",
",",
"value",
")",
":",
"return",
"value"
] | [
308,
4
] | [
313,
20
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.return_insert_columns | (self, fields) |
For backends that support returning columns as part of an insert query,
return the SQL and params to append to the INSERT query. The returned
fragment should contain a format string to hold the appropriate column.
|
For backends that support returning columns as part of an insert query,
return the SQL and params to append to the INSERT query. The returned
fragment should contain a format string to hold the appropriate column.
| def return_insert_columns(self, fields):
"""
For backends that support returning columns as part of an insert query,
return the SQL and params to append to the INSERT query. The returned
fragment should contain a format string to hold the appropriate column.
"""
pass | [
"def",
"return_insert_columns",
"(",
"self",
",",
"fields",
")",
":",
"pass"
] | [
315,
4
] | [
321,
12
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.compiler | (self, compiler_name) |
Return the SQLCompiler class corresponding to the given name,
in the namespace corresponding to the `compiler_module` attribute
on this backend.
|
Return the SQLCompiler class corresponding to the given name,
in the namespace corresponding to the `compiler_module` attribute
on this backend.
| def compiler(self, compiler_name):
"""
Return the SQLCompiler class corresponding to the given name,
in the namespace corresponding to the `compiler_module` attribute
on this backend.
"""
if self._cache is None:
self._cache = import_module(self.compiler_module... | [
"def",
"compiler",
"(",
"self",
",",
"compiler_name",
")",
":",
"if",
"self",
".",
"_cache",
"is",
"None",
":",
"self",
".",
"_cache",
"=",
"import_module",
"(",
"self",
".",
"compiler_module",
")",
"return",
"getattr",
"(",
"self",
".",
"_cache",
",",
... | [
323,
4
] | [
331,
50
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.quote_name | (self, name) |
Return a quoted version of the given table, index, or column name. Do
not quote the given name if it's already been quoted.
|
Return a quoted version of the given table, index, or column name. Do
not quote the given name if it's already been quoted.
| def quote_name(self, name):
"""
Return a quoted version of the given table, index, or column name. Do
not quote the given name if it's already been quoted.
"""
raise NotImplementedError('subclasses of BaseDatabaseOperations may require a quote_name() method') | [
"def",
"quote_name",
"(",
"self",
",",
"name",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a quote_name() method'",
")"
] | [
333,
4
] | [
338,
107
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.random_function_sql | (self) | Return an SQL expression that returns a random value. | Return an SQL expression that returns a random value. | def random_function_sql(self):
"""Return an SQL expression that returns a random value."""
return 'RANDOM()' | [
"def",
"random_function_sql",
"(",
"self",
")",
":",
"return",
"'RANDOM()'"
] | [
340,
4
] | [
342,
25
] | python | en | ['en', 'gd', 'en'] | True |
BaseDatabaseOperations.regex_lookup | (self, lookup_type) |
Return the string to use in a query when performing regular expression
lookups (using "regex" or "iregex"). It should contain a '%s'
placeholder for the column being searched against.
If the feature is not supported (or part of it is not supported), raise
NotImplementedError.
... |
Return the string to use in a query when performing regular expression
lookups (using "regex" or "iregex"). It should contain a '%s'
placeholder for the column being searched against. | def regex_lookup(self, lookup_type):
"""
Return the string to use in a query when performing regular expression
lookups (using "regex" or "iregex"). It should contain a '%s'
placeholder for the column being searched against.
If the feature is not supported (or part of it is not ... | [
"def",
"regex_lookup",
"(",
"self",
",",
"lookup_type",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a regex_lookup() method'",
")"
] | [
344,
4
] | [
353,
109
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.savepoint_create_sql | (self, sid) |
Return the SQL for starting a new savepoint. Only required if the
"uses_savepoints" feature is True. The "sid" parameter is a string
for the savepoint id.
|
Return the SQL for starting a new savepoint. Only required if the
"uses_savepoints" feature is True. The "sid" parameter is a string
for the savepoint id.
| def savepoint_create_sql(self, sid):
"""
Return the SQL for starting a new savepoint. Only required if the
"uses_savepoints" feature is True. The "sid" parameter is a string
for the savepoint id.
"""
return "SAVEPOINT %s" % self.quote_name(sid) | [
"def",
"savepoint_create_sql",
"(",
"self",
",",
"sid",
")",
":",
"return",
"\"SAVEPOINT %s\"",
"%",
"self",
".",
"quote_name",
"(",
"sid",
")"
] | [
355,
4
] | [
361,
52
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.savepoint_commit_sql | (self, sid) |
Return the SQL for committing the given savepoint.
|
Return the SQL for committing the given savepoint.
| def savepoint_commit_sql(self, sid):
"""
Return the SQL for committing the given savepoint.
"""
return "RELEASE SAVEPOINT %s" % self.quote_name(sid) | [
"def",
"savepoint_commit_sql",
"(",
"self",
",",
"sid",
")",
":",
"return",
"\"RELEASE SAVEPOINT %s\"",
"%",
"self",
".",
"quote_name",
"(",
"sid",
")"
] | [
363,
4
] | [
367,
60
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.savepoint_rollback_sql | (self, sid) |
Return the SQL for rolling back the given savepoint.
|
Return the SQL for rolling back the given savepoint.
| def savepoint_rollback_sql(self, sid):
"""
Return the SQL for rolling back the given savepoint.
"""
return "ROLLBACK TO SAVEPOINT %s" % self.quote_name(sid) | [
"def",
"savepoint_rollback_sql",
"(",
"self",
",",
"sid",
")",
":",
"return",
"\"ROLLBACK TO SAVEPOINT %s\"",
"%",
"self",
".",
"quote_name",
"(",
"sid",
")"
] | [
369,
4
] | [
373,
64
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.set_time_zone_sql | (self) |
Return the SQL that will set the connection's time zone.
Return '' if the backend doesn't support time zones.
|
Return the SQL that will set the connection's time zone. | def set_time_zone_sql(self):
"""
Return the SQL that will set the connection's time zone.
Return '' if the backend doesn't support time zones.
"""
return '' | [
"def",
"set_time_zone_sql",
"(",
"self",
")",
":",
"return",
"''"
] | [
375,
4
] | [
381,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.sql_flush | (self, style, tables, sequences, allow_cascade=False) |
Return a list of SQL statements required to remove all data from
the given database tables (without actually removing the tables
themselves) and the SQL statements required to reset the sequences
passed in `sequences`.
The `style` argument is a Style object as returned by eithe... |
Return a list of SQL statements required to remove all data from
the given database tables (without actually removing the tables
themselves) and the SQL statements required to reset the sequences
passed in `sequences`. | def sql_flush(self, style, tables, sequences, allow_cascade=False):
"""
Return a list of SQL statements required to remove all data from
the given database tables (without actually removing the tables
themselves) and the SQL statements required to reset the sequences
passed in `s... | [
"def",
"sql_flush",
"(",
"self",
",",
"style",
",",
"tables",
",",
"sequences",
",",
"allow_cascade",
"=",
"False",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations must provide an sql_flush() method'",
")"
] | [
383,
4
] | [
397,
108
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.execute_sql_flush | (self, using, sql_list) | Execute a list of SQL statements to flush the database. | Execute a list of SQL statements to flush the database. | def execute_sql_flush(self, using, sql_list):
"""Execute a list of SQL statements to flush the database."""
with transaction.atomic(using=using, savepoint=self.connection.features.can_rollback_ddl):
with self.connection.cursor() as cursor:
for sql in sql_list:
... | [
"def",
"execute_sql_flush",
"(",
"self",
",",
"using",
",",
"sql_list",
")",
":",
"with",
"transaction",
".",
"atomic",
"(",
"using",
"=",
"using",
",",
"savepoint",
"=",
"self",
".",
"connection",
".",
"features",
".",
"can_rollback_ddl",
")",
":",
"with"... | [
399,
4
] | [
404,
39
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseOperations.sequence_reset_by_name_sql | (self, style, sequences) |
Return a list of the SQL statements required to reset sequences
passed in `sequences`.
The `style` argument is a Style object as returned by either
color_style() or no_style() in django.core.management.color.
|
Return a list of the SQL statements required to reset sequences
passed in `sequences`. | def sequence_reset_by_name_sql(self, style, sequences):
"""
Return a list of the SQL statements required to reset sequences
passed in `sequences`.
The `style` argument is a Style object as returned by either
color_style() or no_style() in django.core.management.color.
""... | [
"def",
"sequence_reset_by_name_sql",
"(",
"self",
",",
"style",
",",
"sequences",
")",
":",
"return",
"[",
"]"
] | [
406,
4
] | [
414,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.sequence_reset_sql | (self, style, model_list) |
Return a list of the SQL statements required to reset sequences for
the given models.
The `style` argument is a Style object as returned by either
color_style() or no_style() in django.core.management.color.
|
Return a list of the SQL statements required to reset sequences for
the given models. | def sequence_reset_sql(self, style, model_list):
"""
Return a list of the SQL statements required to reset sequences for
the given models.
The `style` argument is a Style object as returned by either
color_style() or no_style() in django.core.management.color.
"""
... | [
"def",
"sequence_reset_sql",
"(",
"self",
",",
"style",
",",
"model_list",
")",
":",
"return",
"[",
"]"
] | [
416,
4
] | [
424,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.start_transaction_sql | (self) | Return the SQL statement required to start a transaction. | Return the SQL statement required to start a transaction. | def start_transaction_sql(self):
"""Return the SQL statement required to start a transaction."""
return "BEGIN;" | [
"def",
"start_transaction_sql",
"(",
"self",
")",
":",
"return",
"\"BEGIN;\""
] | [
426,
4
] | [
428,
23
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseOperations.end_transaction_sql | (self, success=True) | Return the SQL statement required to end a transaction. | Return the SQL statement required to end a transaction. | def end_transaction_sql(self, success=True):
"""Return the SQL statement required to end a transaction."""
if not success:
return "ROLLBACK;"
return "COMMIT;" | [
"def",
"end_transaction_sql",
"(",
"self",
",",
"success",
"=",
"True",
")",
":",
"if",
"not",
"success",
":",
"return",
"\"ROLLBACK;\"",
"return",
"\"COMMIT;\""
] | [
430,
4
] | [
434,
24
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseOperations.tablespace_sql | (self, tablespace, inline=False) |
Return the SQL that will be used in a query to define the tablespace.
Return '' if the backend doesn't support tablespaces.
If `inline` is True, append the SQL to a row; otherwise append it to
the entire CREATE TABLE or CREATE INDEX statement.
|
Return the SQL that will be used in a query to define the tablespace. | def tablespace_sql(self, tablespace, inline=False):
"""
Return the SQL that will be used in a query to define the tablespace.
Return '' if the backend doesn't support tablespaces.
If `inline` is True, append the SQL to a row; otherwise append it to
the entire CREATE TABLE or CR... | [
"def",
"tablespace_sql",
"(",
"self",
",",
"tablespace",
",",
"inline",
"=",
"False",
")",
":",
"return",
"''"
] | [
436,
4
] | [
445,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.prep_for_like_query | (self, x) | Prepare a value for use in a LIKE query. | Prepare a value for use in a LIKE query. | def prep_for_like_query(self, x):
"""Prepare a value for use in a LIKE query."""
return str(x).replace("\\", "\\\\").replace("%", r"\%").replace("_", r"\_") | [
"def",
"prep_for_like_query",
"(",
"self",
",",
"x",
")",
":",
"return",
"str",
"(",
"x",
")",
".",
"replace",
"(",
"\"\\\\\"",
",",
"\"\\\\\\\\\"",
")",
".",
"replace",
"(",
"\"%\"",
",",
"r\"\\%\"",
")",
".",
"replace",
"(",
"\"_\"",
",",
"r\"\\_\"",... | [
447,
4
] | [
449,
83
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseOperations.validate_autopk_value | (self, value) |
Certain backends do not accept some values for "serial" fields
(for example zero in MySQL). Raise a ValueError if the value is
invalid, otherwise return the validated value.
|
Certain backends do not accept some values for "serial" fields
(for example zero in MySQL). Raise a ValueError if the value is
invalid, otherwise return the validated value.
| def validate_autopk_value(self, value):
"""
Certain backends do not accept some values for "serial" fields
(for example zero in MySQL). Raise a ValueError if the value is
invalid, otherwise return the validated value.
"""
return value | [
"def",
"validate_autopk_value",
"(",
"self",
",",
"value",
")",
":",
"return",
"value"
] | [
455,
4
] | [
461,
20
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.adapt_unknown_value | (self, value) |
Transform a value to something compatible with the backend driver.
This method only depends on the type of the value. It's designed for
cases where the target type isn't known, such as .raw() SQL queries.
As a consequence it may not work perfectly in all circumstances.
|
Transform a value to something compatible with the backend driver. | def adapt_unknown_value(self, value):
"""
Transform a value to something compatible with the backend driver.
This method only depends on the type of the value. It's designed for
cases where the target type isn't known, such as .raw() SQL queries.
As a consequence it may not work... | [
"def",
"adapt_unknown_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"datetime",
".",
"datetime",
")",
":",
"# must be before date",
"return",
"self",
".",
"adapt_datetimefield_value",
"(",
"value",
")",
"elif",
"isinstance",... | [
463,
4
] | [
480,
24
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.adapt_datefield_value | (self, value) |
Transform a date value to an object compatible with what is expected
by the backend driver for date columns.
|
Transform a date value to an object compatible with what is expected
by the backend driver for date columns.
| def adapt_datefield_value(self, value):
"""
Transform a date value to an object compatible with what is expected
by the backend driver for date columns.
"""
if value is None:
return None
return str(value) | [
"def",
"adapt_datefield_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"return",
"str",
"(",
"value",
")"
] | [
482,
4
] | [
489,
25
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.adapt_datetimefield_value | (self, value) |
Transform a datetime value to an object compatible with what is expected
by the backend driver for datetime columns.
|
Transform a datetime value to an object compatible with what is expected
by the backend driver for datetime columns.
| def adapt_datetimefield_value(self, value):
"""
Transform a datetime value to an object compatible with what is expected
by the backend driver for datetime columns.
"""
if value is None:
return None
return str(value) | [
"def",
"adapt_datetimefield_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"return",
"str",
"(",
"value",
")"
] | [
491,
4
] | [
498,
25
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.adapt_timefield_value | (self, value) |
Transform a time value to an object compatible with what is expected
by the backend driver for time columns.
|
Transform a time value to an object compatible with what is expected
by the backend driver for time columns.
| def adapt_timefield_value(self, value):
"""
Transform a time value to an object compatible with what is expected
by the backend driver for time columns.
"""
if value is None:
return None
if timezone.is_aware(value):
raise ValueError("Django does no... | [
"def",
"adapt_timefield_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"if",
"timezone",
".",
"is_aware",
"(",
"value",
")",
":",
"raise",
"ValueError",
"(",
"\"Django does not support timezone-aware times.\"",
"... | [
500,
4
] | [
509,
25
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.adapt_decimalfield_value | (self, value, max_digits=None, decimal_places=None) |
Transform a decimal.Decimal value to an object compatible with what is
expected by the backend driver for decimal (numeric) columns.
|
Transform a decimal.Decimal value to an object compatible with what is
expected by the backend driver for decimal (numeric) columns.
| def adapt_decimalfield_value(self, value, max_digits=None, decimal_places=None):
"""
Transform a decimal.Decimal value to an object compatible with what is
expected by the backend driver for decimal (numeric) columns.
"""
return utils.format_number(value, max_digits, decimal_plac... | [
"def",
"adapt_decimalfield_value",
"(",
"self",
",",
"value",
",",
"max_digits",
"=",
"None",
",",
"decimal_places",
"=",
"None",
")",
":",
"return",
"utils",
".",
"format_number",
"(",
"value",
",",
"max_digits",
",",
"decimal_places",
")"
] | [
511,
4
] | [
516,
69
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.adapt_ipaddressfield_value | (self, value) |
Transform a string representation of an IP address into the expected
type for the backend driver.
|
Transform a string representation of an IP address into the expected
type for the backend driver.
| def adapt_ipaddressfield_value(self, value):
"""
Transform a string representation of an IP address into the expected
type for the backend driver.
"""
return value or None | [
"def",
"adapt_ipaddressfield_value",
"(",
"self",
",",
"value",
")",
":",
"return",
"value",
"or",
"None"
] | [
518,
4
] | [
523,
28
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.year_lookup_bounds_for_date_field | (self, value) |
Return a two-elements list with the lower and upper bound to be used
with a BETWEEN operator to query a DateField value using a year
lookup.
`value` is an int, containing the looked-up year.
|
Return a two-elements list with the lower and upper bound to be used
with a BETWEEN operator to query a DateField value using a year
lookup. | def year_lookup_bounds_for_date_field(self, value):
"""
Return a two-elements list with the lower and upper bound to be used
with a BETWEEN operator to query a DateField value using a year
lookup.
`value` is an int, containing the looked-up year.
"""
first = date... | [
"def",
"year_lookup_bounds_for_date_field",
"(",
"self",
",",
"value",
")",
":",
"first",
"=",
"datetime",
".",
"date",
"(",
"value",
",",
"1",
",",
"1",
")",
"second",
"=",
"datetime",
".",
"date",
"(",
"value",
",",
"12",
",",
"31",
")",
"first",
"... | [
525,
4
] | [
537,
30
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.year_lookup_bounds_for_datetime_field | (self, value) |
Return a two-elements list with the lower and upper bound to be used
with a BETWEEN operator to query a DateTimeField value using a year
lookup.
`value` is an int, containing the looked-up year.
|
Return a two-elements list with the lower and upper bound to be used
with a BETWEEN operator to query a DateTimeField value using a year
lookup. | def year_lookup_bounds_for_datetime_field(self, value):
"""
Return a two-elements list with the lower and upper bound to be used
with a BETWEEN operator to query a DateTimeField value using a year
lookup.
`value` is an int, containing the looked-up year.
"""
firs... | [
"def",
"year_lookup_bounds_for_datetime_field",
"(",
"self",
",",
"value",
")",
":",
"first",
"=",
"datetime",
".",
"datetime",
"(",
"value",
",",
"1",
",",
"1",
")",
"second",
"=",
"datetime",
".",
"datetime",
"(",
"value",
",",
"12",
",",
"31",
",",
... | [
539,
4
] | [
555,
30
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.get_db_converters | (self, expression) |
Return a list of functions needed to convert field data.
Some field types on some backends do not provide data in the correct
format, this is the hook for converter functions.
|
Return a list of functions needed to convert field data. | def get_db_converters(self, expression):
"""
Return a list of functions needed to convert field data.
Some field types on some backends do not provide data in the correct
format, this is the hook for converter functions.
"""
return [] | [
"def",
"get_db_converters",
"(",
"self",
",",
"expression",
")",
":",
"return",
"[",
"]"
] | [
557,
4
] | [
564,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.check_expression_support | (self, expression) |
Check that the backend supports the provided expression.
This is used on specific backends to rule out known expressions
that have problematic or nonexistent implementations. If the
expression has a known problem, the backend should raise
NotSupportedError.
|
Check that the backend supports the provided expression. | def check_expression_support(self, expression):
"""
Check that the backend supports the provided expression.
This is used on specific backends to rule out known expressions
that have problematic or nonexistent implementations. If the
expression has a known problem, the backend s... | [
"def",
"check_expression_support",
"(",
"self",
",",
"expression",
")",
":",
"pass"
] | [
570,
4
] | [
579,
12
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.conditional_expression_supported_in_where_clause | (self, expression) |
Return True, if the conditional expression is supported in the WHERE
clause.
|
Return True, if the conditional expression is supported in the WHERE
clause.
| def conditional_expression_supported_in_where_clause(self, expression):
"""
Return True, if the conditional expression is supported in the WHERE
clause.
"""
return True | [
"def",
"conditional_expression_supported_in_where_clause",
"(",
"self",
",",
"expression",
")",
":",
"return",
"True"
] | [
581,
4
] | [
586,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.combine_expression | (self, connector, sub_expressions) |
Combine a list of subexpressions into a single expression, using
the provided connecting operator. This is required because operators
can vary between backends (e.g., Oracle with %% and &) and between
subexpression types (e.g., date expressions).
|
Combine a list of subexpressions into a single expression, using
the provided connecting operator. This is required because operators
can vary between backends (e.g., Oracle with %% and &) and between
subexpression types (e.g., date expressions).
| def combine_expression(self, connector, sub_expressions):
"""
Combine a list of subexpressions into a single expression, using
the provided connecting operator. This is required because operators
can vary between backends (e.g., Oracle with %% and &) and between
subexpression typ... | [
"def",
"combine_expression",
"(",
"self",
",",
"connector",
",",
"sub_expressions",
")",
":",
"conn",
"=",
"' %s '",
"%",
"connector",
"return",
"conn",
".",
"join",
"(",
"sub_expressions",
")"
] | [
588,
4
] | [
596,
41
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.binary_placeholder_sql | (self, value) |
Some backends require special syntax to insert binary content (MySQL
for example uses '_binary %s').
|
Some backends require special syntax to insert binary content (MySQL
for example uses '_binary %s').
| def binary_placeholder_sql(self, value):
"""
Some backends require special syntax to insert binary content (MySQL
for example uses '_binary %s').
"""
return '%s' | [
"def",
"binary_placeholder_sql",
"(",
"self",
",",
"value",
")",
":",
"return",
"'%s'"
] | [
601,
4
] | [
606,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.modify_insert_params | (self, placeholder, params) |
Allow modification of insert parameters. Needed for Oracle Spatial
backend due to #10888.
|
Allow modification of insert parameters. Needed for Oracle Spatial
backend due to #10888.
| def modify_insert_params(self, placeholder, params):
"""
Allow modification of insert parameters. Needed for Oracle Spatial
backend due to #10888.
"""
return params | [
"def",
"modify_insert_params",
"(",
"self",
",",
"placeholder",
",",
"params",
")",
":",
"return",
"params"
] | [
608,
4
] | [
613,
21
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.integer_field_range | (self, internal_type) |
Given an integer field internal type (e.g. 'PositiveIntegerField'),
return a tuple of the (min_value, max_value) form representing the
range of the column type bound to the field.
|
Given an integer field internal type (e.g. 'PositiveIntegerField'),
return a tuple of the (min_value, max_value) form representing the
range of the column type bound to the field.
| def integer_field_range(self, internal_type):
"""
Given an integer field internal type (e.g. 'PositiveIntegerField'),
return a tuple of the (min_value, max_value) form representing the
range of the column type bound to the field.
"""
return self.integer_field_ranges[inter... | [
"def",
"integer_field_range",
"(",
"self",
",",
"internal_type",
")",
":",
"return",
"self",
".",
"integer_field_ranges",
"[",
"internal_type",
"]"
] | [
615,
4
] | [
621,
55
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.window_frame_rows_start_end | (self, start=None, end=None) |
Return SQL for start and end points in an OVER clause window frame.
|
Return SQL for start and end points in an OVER clause window frame.
| def window_frame_rows_start_end(self, start=None, end=None):
"""
Return SQL for start and end points in an OVER clause window frame.
"""
if not self.connection.features.supports_over_clause:
raise NotSupportedError('This backend does not support window expressions.')
... | [
"def",
"window_frame_rows_start_end",
"(",
"self",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"connection",
".",
"features",
".",
"supports_over_clause",
":",
"raise",
"NotSupportedError",
"(",
"'This backend does not... | [
650,
4
] | [
656,
73
] | python | en | ['en', 'error', 'th'] | False |
std_call | (func) |
Returns the correct STDCALL function for certain OSR routines on Win32
platforms.
|
Returns the correct STDCALL function for certain OSR routines on Win32
platforms.
| def std_call(func):
"""
Returns the correct STDCALL function for certain OSR routines on Win32
platforms.
"""
if os.name == 'nt':
return lwingdal[func]
else:
return lgdal[func] | [
"def",
"std_call",
"(",
"func",
")",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"return",
"lwingdal",
"[",
"func",
"]",
"else",
":",
"return",
"lgdal",
"[",
"func",
"]"
] | [
58,
0
] | [
66,
26
] | python | en | ['en', 'error', 'th'] | False |
gdal_version | () | Returns only the GDAL version number information. | Returns only the GDAL version number information. | def gdal_version():
"Returns only the GDAL version number information."
return _version_info(b'RELEASE_NAME') | [
"def",
"gdal_version",
"(",
")",
":",
"return",
"_version_info",
"(",
"b'RELEASE_NAME'",
")"
] | [
76,
0
] | [
78,
41
] | python | en | ['en', 'da', 'en'] | True |
gdal_full_version | () | Returns the full GDAL version information. | Returns the full GDAL version information. | def gdal_full_version():
"Returns the full GDAL version information."
return _version_info('') | [
"def",
"gdal_full_version",
"(",
")",
":",
"return",
"_version_info",
"(",
"''",
")"
] | [
81,
0
] | [
83,
28
] | python | en | ['en', 'no', 'en'] | True |
filesys_decode | (path) |
Ensure that the given path is decoded,
NONE when no expected encoding works
|
Ensure that the given path is decoded,
NONE when no expected encoding works
| def filesys_decode(path):
"""
Ensure that the given path is decoded,
NONE when no expected encoding works
"""
if isinstance(path, six.text_type):
return path
fs_enc = sys.getfilesystemencoding() or 'utf-8'
candidates = fs_enc, 'utf-8'
for enc in candidates:
try:
... | [
"def",
"filesys_decode",
"(",
"path",
")",
":",
"if",
"isinstance",
"(",
"path",
",",
"six",
".",
"text_type",
")",
":",
"return",
"path",
"fs_enc",
"=",
"sys",
".",
"getfilesystemencoding",
"(",
")",
"or",
"'utf-8'",
"candidates",
"=",
"fs_enc",
",",
"'... | [
19,
0
] | [
35,
20
] | python | en | ['en', 'error', 'th'] | False |
try_encode | (string, enc) | turn unicode encoding into a functional routine | turn unicode encoding into a functional routine | def try_encode(string, enc):
"turn unicode encoding into a functional routine"
try:
return string.encode(enc)
except UnicodeEncodeError:
return None | [
"def",
"try_encode",
"(",
"string",
",",
"enc",
")",
":",
"try",
":",
"return",
"string",
".",
"encode",
"(",
"enc",
")",
"except",
"UnicodeEncodeError",
":",
"return",
"None"
] | [
38,
0
] | [
43,
19
] | python | en | ['en', 'en', 'en'] | True |
apply_perturbations | (i, j, X, increase, theta, clip_min, clip_max) |
TensorFlow implementation for apply perturbations to input features based
on saliency maps
:param i: index of first selected feature
:param j: index of second selected feature
:param X: a matrix containing our input features for our sample
:param increase: boolean; true if we are increasing pix... |
TensorFlow implementation for apply perturbations to input features based
on saliency maps
:param i: index of first selected feature
:param j: index of second selected feature
:param X: a matrix containing our input features for our sample
:param increase: boolean; true if we are increasing pix... | def apply_perturbations(i, j, X, increase, theta, clip_min, clip_max):
"""
TensorFlow implementation for apply perturbations to input features based
on saliency maps
:param i: index of first selected feature
:param j: index of second selected feature
:param X: a matrix containing our input featu... | [
"def",
"apply_perturbations",
"(",
"i",
",",
"j",
",",
"X",
",",
"increase",
",",
"theta",
",",
"clip_min",
",",
"clip_max",
")",
":",
"warnings",
".",
"warn",
"(",
"\"This function is dead code and will be removed on or after 2019-07-18\"",
")",
"# perturb our input ... | [
90,
0
] | [
115,
12
] | python | en | ['en', 'error', 'th'] | False |
saliency_map | (grads_target, grads_other, search_domain, increase) |
TensorFlow implementation for computing saliency maps
:param grads_target: a matrix containing forward derivatives for the
target class
:param grads_other: a matrix where every element is the sum of forward
derivatives over all non-target classes at that ind... |
TensorFlow implementation for computing saliency maps
:param grads_target: a matrix containing forward derivatives for the
target class
:param grads_other: a matrix where every element is the sum of forward
derivatives over all non-target classes at that ind... | def saliency_map(grads_target, grads_other, search_domain, increase):
"""
TensorFlow implementation for computing saliency maps
:param grads_target: a matrix containing forward derivatives for the
target class
:param grads_other: a matrix where every element is the sum of forwar... | [
"def",
"saliency_map",
"(",
"grads_target",
",",
"grads_other",
",",
"search_domain",
",",
"increase",
")",
":",
"warnings",
".",
"warn",
"(",
"\"This function is dead code and will be removed on or after 2019-07-18\"",
")",
"# Compute the size of the input (the number of feature... | [
118,
0
] | [
167,
32
] | python | en | ['en', 'error', 'th'] | False |
jacobian | (sess, x, grads, target, X, nb_features, nb_classes, feed=None) |
TensorFlow implementation of the foward derivative / Jacobian
:param x: the input placeholder
:param grads: the list of TF gradients returned by jacobian_graph()
:param target: the target misclassification class
:param X: numpy array with sample input
:param nb_features: the number of features ... |
TensorFlow implementation of the foward derivative / Jacobian
:param x: the input placeholder
:param grads: the list of TF gradients returned by jacobian_graph()
:param target: the target misclassification class
:param X: numpy array with sample input
:param nb_features: the number of features ... | def jacobian(sess, x, grads, target, X, nb_features, nb_classes, feed=None):
"""
TensorFlow implementation of the foward derivative / Jacobian
:param x: the input placeholder
:param grads: the list of TF gradients returned by jacobian_graph()
:param target: the target misclassification class
:pa... | [
"def",
"jacobian",
"(",
"sess",
",",
"x",
",",
"grads",
",",
"target",
",",
"X",
",",
"nb_features",
",",
"nb_classes",
",",
"feed",
"=",
"None",
")",
":",
"warnings",
".",
"warn",
"(",
"\"This function is dead code and will be removed on or after 2019-07-18\"",
... | [
170,
0
] | [
202,
44
] | python | en | ['en', 'error', 'th'] | False |
SessionStore.create_model_instance | (self, data) |
Return a new instance of the session model object, which represents the
current session state. Intended to be used for saving the session data
to the database.
|
Return a new instance of the session model object, which represents the
current session state. Intended to be used for saving the session data
to the database.
| def create_model_instance(self, data):
"""
Return a new instance of the session model object, which represents the
current session state. Intended to be used for saving the session data
to the database.
"""
return self.model(
session_key=self._get_or_create_se... | [
"def",
"create_model_instance",
"(",
"self",
",",
"data",
")",
":",
"return",
"self",
".",
"model",
"(",
"session_key",
"=",
"self",
".",
"_get_or_create_session_key",
"(",
")",
",",
"session_data",
"=",
"self",
".",
"encode",
"(",
"data",
")",
",",
"expir... | [
61,
4
] | [
71,
9
] | python | en | ['en', 'error', 'th'] | False |
SessionStore.save | (self, must_create=False) |
Save the current session data to the database. If 'must_create' is
True, raise a database error if the saving operation doesn't create a
new entry (as opposed to possibly updating an existing entry).
|
Save the current session data to the database. If 'must_create' is
True, raise a database error if the saving operation doesn't create a
new entry (as opposed to possibly updating an existing entry).
| def save(self, must_create=False):
"""
Save the current session data to the database. If 'must_create' is
True, raise a database error if the saving operation doesn't create a
new entry (as opposed to possibly updating an existing entry).
"""
if self.session_key is None:
... | [
"def",
"save",
"(",
"self",
",",
"must_create",
"=",
"False",
")",
":",
"if",
"self",
".",
"session_key",
"is",
"None",
":",
"return",
"self",
".",
"create",
"(",
")",
"data",
"=",
"self",
".",
"_get_session",
"(",
"no_load",
"=",
"must_create",
")",
... | [
73,
4
] | [
94,
17
] | python | en | ['en', 'error', 'th'] | False |
check_union | (allowed_type_funcs: Iterable[Validator[ResultT]]) |
Use this validator if an argument is of a variable type (e.g. processing
properties that might be strings or booleans).
`allowed_type_funcs`: the check_* validator functions for the possible data
types for this variable.
|
Use this validator if an argument is of a variable type (e.g. processing
properties that might be strings or booleans). | def check_union(allowed_type_funcs: Iterable[Validator[ResultT]]) -> Validator[ResultT]:
"""
Use this validator if an argument is of a variable type (e.g. processing
properties that might be strings or booleans).
`allowed_type_funcs`: the check_* validator functions for the possible data
types for ... | [
"def",
"check_union",
"(",
"allowed_type_funcs",
":",
"Iterable",
"[",
"Validator",
"[",
"ResultT",
"]",
"]",
")",
"->",
"Validator",
"[",
"ResultT",
"]",
":",
"def",
"enumerated_type_check",
"(",
"var_name",
":",
"str",
",",
"val",
":",
"object",
")",
"->... | [
294,
0
] | [
311,
32
] | python | en | ['en', 'error', 'th'] | False |
validate_select_field_data | (field_data: ProfileFieldData) |
This function is used to validate the data sent to the server while
creating/editing choices of the choice field in Organization settings.
|
This function is used to validate the data sent to the server while
creating/editing choices of the choice field in Organization settings.
| def validate_select_field_data(field_data: ProfileFieldData) -> Dict[str, Dict[str, str]]:
"""
This function is used to validate the data sent to the server while
creating/editing choices of the choice field in Organization settings.
"""
validator = check_dict_only(
[
("text", ch... | [
"def",
"validate_select_field_data",
"(",
"field_data",
":",
"ProfileFieldData",
")",
"->",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"str",
"]",
"]",
":",
"validator",
"=",
"check_dict_only",
"(",
"[",
"(",
"\"text\"",
",",
"check_required_string",
... | [
359,
0
] | [
378,
54
] | python | en | ['en', 'error', 'th'] | False |
validate_select_field | (var_name: str, field_data: str, value: object) |
This function is used to validate the value selected by the user against a
choice field. This is not used to validate admin data.
|
This function is used to validate the value selected by the user against a
choice field. This is not used to validate admin data.
| def validate_select_field(var_name: str, field_data: str, value: object) -> str:
"""
This function is used to validate the value selected by the user against a
choice field. This is not used to validate admin data.
"""
s = check_string(var_name, value)
field_data_dict = orjson.loads(field_data)
... | [
"def",
"validate_select_field",
"(",
"var_name",
":",
"str",
",",
"field_data",
":",
"str",
",",
"value",
":",
"object",
")",
"->",
"str",
":",
"s",
"=",
"check_string",
"(",
"var_name",
",",
"value",
")",
"field_data_dict",
"=",
"orjson",
".",
"loads",
... | [
381,
0
] | [
391,
12
] | python | en | ['en', 'error', 'th'] | False |
ProxyModelTests.test_same_manager_queries | (self) |
The MyPerson model should be generating the same database queries as
the Person model (when the same manager is used in each case).
|
The MyPerson model should be generating the same database queries as
the Person model (when the same manager is used in each case).
| def test_same_manager_queries(self):
"""
The MyPerson model should be generating the same database queries as
the Person model (when the same manager is used in each case).
"""
my_person_sql = MyPerson.other.all().query.get_compiler(
DEFAULT_DB_ALIAS).as_sql()
... | [
"def",
"test_same_manager_queries",
"(",
"self",
")",
":",
"my_person_sql",
"=",
"MyPerson",
".",
"other",
".",
"all",
"(",
")",
".",
"query",
".",
"get_compiler",
"(",
"DEFAULT_DB_ALIAS",
")",
".",
"as_sql",
"(",
")",
"person_sql",
"=",
"Person",
".",
"ob... | [
20,
4
] | [
29,
51
] | python | en | ['en', 'error', 'th'] | False |
ProxyModelTests.test_inheretance_new_table | (self) |
The StatusPerson models should have its own table (it's using ORM-level
inheritance).
|
The StatusPerson models should have its own table (it's using ORM-level
inheritance).
| def test_inheretance_new_table(self):
"""
The StatusPerson models should have its own table (it's using ORM-level
inheritance).
"""
sp_sql = StatusPerson.objects.all().query.get_compiler(
DEFAULT_DB_ALIAS).as_sql()
p_sql = Person.objects.all().query.get_compil... | [
"def",
"test_inheretance_new_table",
"(",
"self",
")",
":",
"sp_sql",
"=",
"StatusPerson",
".",
"objects",
".",
"all",
"(",
")",
".",
"query",
".",
"get_compiler",
"(",
"DEFAULT_DB_ALIAS",
")",
".",
"as_sql",
"(",
")",
"p_sql",
"=",
"Person",
".",
"objects... | [
31,
4
] | [
40,
42
] | python | en | ['en', 'error', 'th'] | False |
ProxyModelTests.test_basic_proxy | (self) |
Creating a Person makes them accessible through the MyPerson proxy.
|
Creating a Person makes them accessible through the MyPerson proxy.
| def test_basic_proxy(self):
"""
Creating a Person makes them accessible through the MyPerson proxy.
"""
person = Person.objects.create(name="Foo McBar")
self.assertEqual(len(Person.objects.all()), 1)
self.assertEqual(len(MyPerson.objects.all()), 1)
self.assertEqua... | [
"def",
"test_basic_proxy",
"(",
"self",
")",
":",
"person",
"=",
"Person",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"\"Foo McBar\"",
")",
"self",
".",
"assertEqual",
"(",
"len",
"(",
"Person",
".",
"objects",
".",
"all",
"(",
")",
")",
",",
"... | [
42,
4
] | [
50,
79
] | python | en | ['en', 'error', 'th'] | False |
ProxyModelTests.test_no_proxy | (self) |
Person is not proxied by StatusPerson subclass.
|
Person is not proxied by StatusPerson subclass.
| def test_no_proxy(self):
"""
Person is not proxied by StatusPerson subclass.
"""
Person.objects.create(name="Foo McBar")
self.assertEqual(list(StatusPerson.objects.all()), []) | [
"def",
"test_no_proxy",
"(",
"self",
")",
":",
"Person",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"\"Foo McBar\"",
")",
"self",
".",
"assertEqual",
"(",
"list",
"(",
"StatusPerson",
".",
"objects",
".",
"all",
"(",
")",
")",
",",
"[",
"]",
")... | [
52,
4
] | [
57,
62
] | python | en | ['en', 'error', 'th'] | False |
ProxyModelTests.test_basic_proxy_reverse | (self) |
A new MyPerson also shows up as a standard Person.
|
A new MyPerson also shows up as a standard Person.
| def test_basic_proxy_reverse(self):
"""
A new MyPerson also shows up as a standard Person.
"""
MyPerson.objects.create(name="Bazza del Frob")
self.assertEqual(len(MyPerson.objects.all()), 1)
self.assertEqual(len(Person.objects.all()), 1)
LowerStatusPerson.objects... | [
"def",
"test_basic_proxy_reverse",
"(",
"self",
")",
":",
"MyPerson",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"\"Bazza del Frob\"",
")",
"self",
".",
"assertEqual",
"(",
"len",
"(",
"MyPerson",
".",
"objects",
".",
"all",
"(",
")",
")",
",",
"1"... | [
59,
4
] | [
69,
41
] | python | en | ['en', 'error', 'th'] | False |
ProxyModelTests.test_correct_type_proxy_of_proxy | (self) |
Correct type when querying a proxy of proxy
|
Correct type when querying a proxy of proxy
| def test_correct_type_proxy_of_proxy(self):
"""
Correct type when querying a proxy of proxy
"""
Person.objects.create(name="Foo McBar")
MyPerson.objects.create(name="Bazza del Frob")
LowerStatusPerson.objects.create(status="low", name="homer")
pp = sorted(mpp.name... | [
"def",
"test_correct_type_proxy_of_proxy",
"(",
"self",
")",
":",
"Person",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"\"Foo McBar\"",
")",
"MyPerson",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"\"Bazza del Frob\"",
")",
"LowerStatusPerson",
".",
... | [
71,
4
] | [
79,
70
] | python | en | ['en', 'error', 'th'] | False |
ProxyModelTests.test_proxy_included_in_ancestors | (self) |
Proxy models are included in the ancestors for a model's DoesNotExist
and MultipleObjectsReturned
|
Proxy models are included in the ancestors for a model's DoesNotExist
and MultipleObjectsReturned
| def test_proxy_included_in_ancestors(self):
"""
Proxy models are included in the ancestors for a model's DoesNotExist
and MultipleObjectsReturned
"""
Person.objects.create(name="Foo McBar")
MyPerson.objects.create(name="Bazza del Frob")
LowerStatusPerson.objects.c... | [
"def",
"test_proxy_included_in_ancestors",
"(",
"self",
")",
":",
"Person",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"\"Foo McBar\"",
")",
"MyPerson",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"\"Bazza del Frob\"",
")",
"LowerStatusPerson",
".",
... | [
81,
4
] | [
115,
9
] | python | en | ['en', 'error', 'th'] | False |
ProxyModelTests.test_abc | (self) |
All base classes must be non-abstract
|
All base classes must be non-abstract
| def test_abc(self):
"""
All base classes must be non-abstract
"""
def build_abc():
class NoAbstract(Abstract):
class Meta:
proxy = True
self.assertRaises(TypeError, build_abc) | [
"def",
"test_abc",
"(",
"self",
")",
":",
"def",
"build_abc",
"(",
")",
":",
"class",
"NoAbstract",
"(",
"Abstract",
")",
":",
"class",
"Meta",
":",
"proxy",
"=",
"True",
"self",
".",
"assertRaises",
"(",
"TypeError",
",",
"build_abc",
")"
] | [
117,
4
] | [
125,
47
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.