Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e264a94
docs for base
tina80lvl Nov 25, 2020
5069132
docs for client
tina80lvl Nov 25, 2020
ca9c7ce
docs for compiler
tina80lvl Nov 26, 2020
1a6257a
docs for expressions
tina80lvl Nov 26, 2020
cfdba5f
docs for features
tina80lvl Nov 26, 2020
2b742f8
docs for functions
tina80lvl Nov 26, 2020
a82bf1b
docs for introspection
tina80lvl Nov 26, 2020
b819547
resolving conflict
tina80lvl Nov 26, 2020
321858f
docs for lookups
tina80lvl Nov 26, 2020
e77b4e9
docs for operations
tina80lvl Dec 3, 2020
4db2d4a
docs for schema
tina80lvl Dec 3, 2020
115881f
docs for utils
tina80lvl Dec 3, 2020
0647468
docs: updates to `base.py`
mf2199 Dec 3, 2020
6970b97
docs: updates to `client.py`
mf2199 Dec 3, 2020
8dab421
docs for validation
tina80lvl Dec 3, 2020
04a0cac
docs: updates to `complier.py`
mf2199 Dec 3, 2020
c2a09f0
Merge branch 'docstr-2' of https://github.com/q-logic/python-spanner-…
mf2199 Dec 3, 2020
0d2ec73
docs: updates to `creation.py`
mf2199 Dec 3, 2020
3a6e84a
docs: updates to `expressions.py`
mf2199 Dec 3, 2020
1479a2f
docs: updates to `features.py`
mf2199 Dec 3, 2020
c902cd2
docs: updates to `functions.py`
mf2199 Dec 3, 2020
6cfb4a5
docs: updates to `introspection.py`
mf2199 Dec 3, 2020
5580621
docs: updates to `lookups.py`
mf2199 Dec 3, 2020
7deb3d3
docs: updates to `operations.py`
mf2199 Dec 3, 2020
ed86c06
Merge branch 'master' into docstr-2
c24t Dec 7, 2020
67106fa
fix: docstrings
mf2199 Dec 7, 2020
c9364d0
fix: typo
mf2199 Dec 8, 2020
678ecb3
fix: docstrings
mf2199 Dec 9, 2020
0b84fb6
fix: single quotes
tina80lvl Dec 9, 2020
583398d
fix: docstrings typing
tina80lvl Dec 9, 2020
2afc4eb
Remove runshell docstring
c24t Dec 10, 2020
d36b9ab
Remove some TODOs from docstrings
c24t Dec 10, 2020
117484b
Merge branch 'master' into docstr-2
c24t Dec 15, 2020
5240d21
Fix operations docstrings
c24t Dec 15, 2020
499c61a
Merge branch 'master' into docstr-2
mf2199 Dec 16, 2020
d749356
docs: docstrings
mf2199 Dec 16, 2020
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs for functions
  • Loading branch information
tina80lvl committed Nov 26, 2020
commit 2b742f82a62c9436a3fde07ce5f95e9a02f9693d
85 changes: 85 additions & 0 deletions django_spanner/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ class IfNull(Func):


def cast(self, compiler, connection, **extra_context):
"""Cast SQL query for given parameters.

TODO: describe all parameters when code will be ready.

:rtype: str
:returns: A SQL query.
"""
# Account for a field's max_length using SUBSTR.
max_length = getattr(self.output_field, "max_length", None)
if max_length is not None:
Expand All @@ -42,6 +49,13 @@ def cast(self, compiler, connection, **extra_context):


def chr_(self, compiler, connection, **extra_context):
"""Return a SQL query where the code points are displayed as a string.

TODO: describe all parameters when code will be ready.

:rtype: str
:returns: A SQL query.
"""
return self.as_sql(
compiler,
connection,
Expand All @@ -51,6 +65,13 @@ def chr_(self, compiler, connection, **extra_context):


def concatpair(self, compiler, connection, **extra_context):
"""Concatenates a SQL query into the sequence of :class:`IfNull` objects.

TODO: describe all parameters when code will be ready.

:rtype: str
:returns: A SQL query.
"""
# Spanner's CONCAT function returns null if any of its arguments are null.
# Prevent that by converting null arguments to an empty string.
clone = self.copy()
Expand All @@ -61,6 +82,13 @@ def concatpair(self, compiler, connection, **extra_context):


def cot(self, compiler, connection, **extra_context):
"""Return a SQL query of calculated cotangent.

TODO: describe all parameters when code will be ready.

:rtype: str
:returns: A SQL query.
"""
return self.as_sql(
compiler,
connection,
Expand All @@ -70,6 +98,13 @@ def cot(self, compiler, connection, **extra_context):


def degrees(self, compiler, connection, **extra_context):
"""Return a SQL query of the angle converted to degrees.

TODO: describe all parameters when code will be ready.

:rtype: str
:returns: A SQL query.
"""
return self.as_sql(
compiler,
connection,
Expand All @@ -79,10 +114,24 @@ def degrees(self, compiler, connection, **extra_context):


def left_and_right(self, compiler, connection, **extra_context):
"""

TODO: describe all parameters when code will be ready.

:rtype: str
:returns: A SQL query.
"""
return self.get_substr().as_spanner(compiler, connection, **extra_context)


def log(self, compiler, connection, **extra_context):
"""Return a SQL query of calculated logarithm.

TODO: describe all parameters when code will be ready.

:rtype: str
:returns: A SQL query.
"""
# This function is usually Log(b, x) returning the logarithm of x to the
# base b, but on Spanner it's Log(x, b).
clone = self.copy()
Expand All @@ -91,6 +140,13 @@ def log(self, compiler, connection, **extra_context):


def ord_(self, compiler, connection, **extra_context):
"""Return a SQL query of the expression converted to ord.

TODO: describe all parameters when code will be ready.

:rtype: str
:returns: A SQL query.
"""
return self.as_sql(
compiler,
connection,
Expand All @@ -100,12 +156,26 @@ def ord_(self, compiler, connection, **extra_context):


def pi(self, compiler, connection, **extra_context):
"""Return a SQL query of PI constant.

TODO: describe all parameters when code will be ready.

:rtype: str
:returns: A SQL query.
"""
return self.as_sql(
compiler, connection, template=str(math.pi), **extra_context
)


def radians(self, compiler, connection, **extra_context):
"""Return a SQL query of the angle converted to radians.

TODO: describe all parameters when code will be ready.

:rtype: str
:returns: A SQL query.
"""
return self.as_sql(
compiler,
connection,
Expand All @@ -115,18 +185,33 @@ def radians(self, compiler, connection, **extra_context):


def strindex(self, compiler, connection, **extra_context):
"""Return a SQL query of the string position.

TODO: describe all parameters when code will be ready.

:rtype: str
:returns: A SQL query.
"""
return self.as_sql(
compiler, connection, function="STRPOS", **extra_context
)


def substr(self, compiler, connection, **extra_context):
"""Return a SQL query of substring.

TODO: describe all parameters when code will be ready.

:rtype: str
:returns: A SQL query.
"""
return self.as_sql(
compiler, connection, function="SUBSTR", **extra_context
)


def register_functions():
"""Register functions in Spanner."""
Cast.as_spanner = cast
Chr.as_spanner = chr_
ConcatPair.as_spanner = concatpair
Expand Down