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

Function field

pattern/db/__init__.py:700–722  ·  view source on GitHub ↗

Returns a table field definition that can be passed to Database.create(). The column can be indexed by setting index to True, PRIMARY or UNIQUE. Primary key number columns are always auto-incremented.

(name, type=STRING, **kwargs)

Source from the content-addressed store, hash-verified

698
699#def field(name, type=STRING, default=None, index=False, optional=True)
700def field(name, type=STRING, **kwargs):
701 """ Returns a table field definition that can be passed to Database.create().
702 The column can be indexed by setting index to True, PRIMARY or UNIQUE.
703 Primary key number columns are always auto-incremented.
704 """
705 default, index, optional = (
706 kwargs.get("default", type == DATE and NOW or None),
707 kwargs.get("index", False),
708 kwargs.get("optional", True)
709 )
710 if type == STRING:
711 type = STRING()
712 if type == FLOAT:
713 type = "real"
714 if type == BOOLEAN:
715 type = "tinyint(1)"
716 if type == DATE:
717 type = "timestamp"
718 if str(index) in "01":
719 index = bool(int(index))
720 if str(optional) in "01":
721 optional = bool(int(optional))
722 return (name, type, default, index, optional)
723
724_field = field
725

Callers 3

01-database.pyFile · 0.90
primary_keyFunction · 0.85
parse_xmlFunction · 0.85

Calls 2

strFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…