MCPcopy Index your code
hub / github.com/clips/pattern / abs

Function abs

pattern/db/__init__.py:1019–1032  ·  view source on GitHub ↗

For a given , returns the absolute . . This is useful when constructing queries with relations to other tables.

(table, field)

Source from the content-addressed store, hash-verified

1017 "strftime|date_format"
1018
1019def abs(table, field):
1020 """ For a given <fieldname>, returns the absolute <tablename>.<fieldname>.
1021 This is useful when constructing queries with relations to other tables.
1022 """
1023 def _format(s):
1024 if not "." in s:
1025 # Field could be wrapped in a function: year(date) => year(table.date).
1026 p = s.endswith(")") and re.match(r"^("+sql_functions+r")\(", s, re.I) or None
1027 i = p and len(p.group(0)) or 0
1028 return "%s%s.%s" % (s[:i], table, s[i:])
1029 return s
1030 if isinstance(field, (list, tuple)):
1031 return [_format(f) for f in field]
1032 return _format(field)
1033
1034def cmp(field, value, comparison="=", escape=lambda v: _escape(v), table=""):
1035 """ Returns an SQL WHERE comparison string using =, i=, !=, >, <, >=, <= or BETWEEN.

Callers 15

absMethod · 0.70
cmpFunction · 0.70
SQLMethod · 0.70
gsFunction · 0.50
gfFunction · 0.50
erfcFunction · 0.50
pdfFunction · 0.50
distanceFunction · 0.50
containsMethod · 0.50
eigenvector_centralityFunction · 0.50
nearestMethod · 0.50
numeralsFunction · 0.50

Calls 1

_formatFunction · 0.70

Tested by 2

test_boxplotMethod · 0.40
test_model_reduceMethod · 0.40