Check-in [0caa6b62ab]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use between operator for numeric property range constraints instead of the relational operators.
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1: 0caa6b62ab52d3f7c49c038f2c966ee2be1855e9
User & Date: mvnathan 2014-09-18 21:13:18.262
Context
2014-09-19
00:33
Added a helper class to ease database Morgification and verification. check-in: 5013209038 user: mvnathan tags: dev
2014-09-18
21:13
Use between operator for numeric property range constraints instead of the relational operators. check-in: 0caa6b62ab user: mvnathan tags: dev
21:07
Updated morglib.database documentation. check-in: f2db928450 user: mvnathan tags: dev
Changes
Unified Diff Ignore Whitespace Patch
Changes to py/morglib/database.py.
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
                                 "more than one .. in " +
                                 "numeric column's range spec")
        try:
            ctor = int if (column_type == 'integer') else float
            bounds = map(lambda v: ctor(v), bounds)
        except Exception, e:
            raise property_error(column_name, column_type, range_spec, e)
        return ('check ({} >= {} and {} <= {})'.
                format(column_name, min(bounds),
                       column_name, max(bounds)))

    # Assume we're dealing with discrete values
    if (column_type == 'text'):
        fmt = lambda v: "'{}'".format(v)
    elif (column_type == 'integer'):
        fmt = lambda v: '{}'.format(int(v))
    else:







|
|
<







626
627
628
629
630
631
632
633
634

635
636
637
638
639
640
641
                                 "more than one .. in " +
                                 "numeric column's range spec")
        try:
            ctor = int if (column_type == 'integer') else float
            bounds = map(lambda v: ctor(v), bounds)
        except Exception, e:
            raise property_error(column_name, column_type, range_spec, e)
        return ('check ({} between {} and {})'.
                format(column_name, min(bounds), max(bounds)))


    # Assume we're dealing with discrete values
    if (column_type == 'text'):
        fmt = lambda v: "'{}'".format(v)
    elif (column_type == 'integer'):
        fmt = lambda v: '{}'.format(int(v))
    else:
Changes to wiki/todo.wiki.
15
16
17
18
19
20
21

22
23
24
25
26
27
28
29
  *  Create <tt>morg</tt> table on database init.
  *  Create <tt>task</tt> table on database init.
  *  Create <tt>property</tt> table on database init.
  *  Add default properties dict.
  *  Create <tt>property_NNN</tt> tables on database init.
  *  Implement sanity check on database initialization.
  *  Update database constructor doc string.


<h2>PENDING</h2>

  *  Use the BETWEEN operator in property range constraints.
  *  Implement a watermark class to ease verification and "Morgification."
  *  The watermark table should be created and populated in a transaction.
  *  Pass database to all commands' <tt>__call__</tt> method.
  *  Implement <tt>new</tt> command.







>



<




15
16
17
18
19
20
21
22
23
24
25

26
27
28
29
  *  Create <tt>morg</tt> table on database init.
  *  Create <tt>task</tt> table on database init.
  *  Create <tt>property</tt> table on database init.
  *  Add default properties dict.
  *  Create <tt>property_NNN</tt> tables on database init.
  *  Implement sanity check on database initialization.
  *  Update database constructor doc string.
  *  Use the BETWEEN operator in property range constraints.

<h2>PENDING</h2>


  *  Implement a watermark class to ease verification and "Morgification."
  *  The watermark table should be created and populated in a transaction.
  *  Pass database to all commands' <tt>__call__</tt> method.
  *  Implement <tt>new</tt> command.