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
25 | 25 |
from sqlalchemy import Column, Integer, String, BigInteger
|
26 | 26 |
from sqlalchemy import ForeignKey, DateTime, Boolean, Text
|
27 | 27 |
from sqlalchemy import UniqueConstraint
|
|
28 |
from sqlalchemy.ext.compiler import compiles
|
28 | 29 |
from sqlalchemy.ext.declarative import declarative_base
|
29 | 30 |
|
30 | 31 |
import glance.registry.db.api
|
31 | 32 |
from glance.common import utils
|
32 | 33 |
|
33 | 34 |
BASE = declarative_base()
|
|
35 |
|
|
36 |
|
|
37 |
@compiles(BigInteger, 'sqlite')
|
|
38 |
def compile_big_int_sqlite(type_, compiler, **kw):
|
|
39 |
return 'INTEGER'
|
34 | 40 |
|
35 | 41 |
|
36 | 42 |
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()
|