Commit cde44651 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

support for a new BigInt base type. Closes #68099

parent 20f6b185688b
ChangeLog for yams
------------------
--
* support BigInt
2011-04-01 -- 0.32.0
* support TZDatetime and TZTime
......
......@@ -34,7 +34,7 @@ from yams._exceptions import *
MARKER = nullobject()
BASE_TYPES = set(('String', 'Password', 'Bytes',
'Int', 'Float', 'Boolean', 'Decimal',
'Int', 'BigInt', 'Float', 'Boolean', 'Decimal',
'Date', 'Time', 'Datetime', 'TZTime', 'TZDatetime', 'Interval'
))
......
# copyright 2004-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# copyright 2004-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of yams.
......@@ -505,6 +505,7 @@ BASE_CHECKERS = {
'Interval' : yes,
'String' : check_string,
'Int' : check_int,
'BigInt' : check_int,
'Float' : check_float,
'Decimal' : check_decimal,
'Boolean' : check_boolean,
......@@ -516,6 +517,7 @@ BASE_CONVERTERS = {
'String' : unicode,
'Password': str,
'Int' : int,
'BigInt' : int,
'Float' : float,
'Boolean' : bool,
'Decimal' : decimal.Decimal,
......
......@@ -387,8 +387,8 @@ class EntitySchema(PermissionMixIn, ERSchema):
if rdef.object == 'Boolean':
if not isinstance(default, bool):
default = default == 'True' # XXX duh?
elif rdef.object == 'Int':
if not isinstance(default, int):
elif rdef.object in ('Int', 'BigInt'):
if not isinstance(default, (int, long)):
default = int(default)
elif rdef.object == 'Float':
if not isinstance(default, float):
......
......@@ -128,7 +128,7 @@ def aschema2sql(dbhelper, eschema, rschema, aschema, creating=True, indent=''):
sqltype += ' DEFAULT %s' % dbhelper.boolean_value(default)
elif aschema.type == 'String':
sqltype += ' DEFAULT %r' % str(default)
elif aschema.type in ('Int', 'Float'):
elif aschema.type in ('Int', 'BigInt', 'Float'):
sqltype += ' DEFAULT %s' % default
# XXX ignore default for other type
# this is expected for NOW / TODAY
......
# copyright 2004-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# copyright 2004-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of yams.
......@@ -53,7 +53,8 @@ class SchemaLoaderTC(TestCase):
self.assert_(isinstance(schema, Schema))
self.assertEqual(schema.name, 'NoName')
self.assertListEqual(sorted(schema.entities()),
['Affaire', 'Boolean', 'Bytes', 'Company', 'Date', 'Datetest', 'Datetime', 'Decimal',
['Affaire', 'BigInt', 'Boolean', 'Bytes', 'Company',
'Date', 'Datetest', 'Datetime', 'Decimal',
'Division', 'EPermission', 'Eetype', 'Employee', 'Float', 'Int', 'Interval',
'Note', 'Password', 'Person', 'Societe', 'State', 'String',
'Subcompany', 'Subdivision', 'TZDatetime', 'TZTime', 'Time', 'pkginfo'])
......
# -*- coding: iso-8859-1 -*-
# copyright 2004-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# copyright 2004-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of yams.
......@@ -380,7 +380,7 @@ class SchemaTC(BaseSchemaTC):
def test_schema_base(self):
"""test base schema methods
"""
all_types = ['Affaire', 'Boolean', 'Bytes', 'Date', 'Datetime',
all_types = ['Affaire', 'BigInt', 'Boolean', 'Bytes', 'Date', 'Datetime',
'Decimal',
'Float', 'Int', 'Interval', 'Note', 'Password',
'Person', 'Societe', 'String', 'TZDatetime', 'TZTime', 'Time']
......@@ -459,7 +459,7 @@ class SchemaTC(BaseSchemaTC):
orig_rprops = affaire.rdef('concerne')
schema.rename_entity_type('Affaire', 'Workcase')
self.assertItemsEqual(schema._entities.keys(),
['Boolean', 'Bytes', 'Date', 'Datetime', 'Float',
['BigInt', 'Boolean', 'Bytes', 'Date', 'Datetime', 'Float',
'Decimal',
'Int', 'Interval', 'Note', 'Password', 'Person',
'Societe', 'String', 'Time', 'TZDatetime', 'TZTime',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment