Codebase list glance / 0d4d1f7
Compile BigInteger to INTEGER for sqlite Fixes bug 966243 Ensure BigInteger does not map to BIGINT for an auto-created sqlite registry DB, as this type is not supported by sqlite. Change-Id: I61f44fbe50ea406d2d593f8f53cab5da3af2222a Eoghan Glynn authored 12 years ago Brian Waldon committed 12 years ago
2 changed file(s) with 45 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
2525 from sqlalchemy import Column, Integer, String, BigInteger
2626 from sqlalchemy import ForeignKey, DateTime, Boolean, Text
2727 from sqlalchemy import UniqueConstraint
28 from sqlalchemy.ext.compiler import compiles
2829 from sqlalchemy.ext.declarative import declarative_base
2930
3031 import glance.registry.db.api
3132 from glance.common import utils
3233
3334 BASE = declarative_base()
35
36
37 @compiles(BigInteger, 'sqlite')
38 def compile_big_int_sqlite(type_, compiler, **kw):
39 return 'INTEGER'
3440
3541
3642 class ModelBase(object):
0 # vim: tabstop=4 shiftwidth=4 softtabstop=4
1
2 # Copyright 2012 Red Hat, Inc
3 # All Rights Reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); you may
6 # not use this file except in compliance with the License. You may obtain
7 # a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 # License for the specific language governing permissions and limitations
15 # under the License.
16
17 """Functional test cases for sqlite-specific logic"""
18
19
20 from glance.tests import functional
21 from glance.tests.utils import execute
22
23
24 class TestSqlite(functional.FunctionalTest):
25 """Functional tests for sqlite-specific logic"""
26
27 @functional.runs_sql
28 def test_big_int_mapping(self):
29 """Ensure BigInteger not mapped to BIGINT"""
30 self.cleanup()
31 self.start_servers(**self.__dict__.copy())
32
33 cmd = "sqlite3 tests.sqlite '.schema'"
34 exitcode, out, err = execute(cmd, raise_error=True)
35
36 self.assertFalse('BIGINT' in out)
37
38 self.stop_servers()