Commit 6ef8d48f authored by Adrien Di Mascio's avatar Adrien Di Mascio

provide sqlite serializer for arrays (closes #3036179)

parent 2e6f2312d2db
import json
from logilab.database import get_db_helper, FunctionDescr
from logilab.database.sqlgen import SQLExpression
from yams import register_base_type
register_base_type('IntArray', ('size',))
register_base_type('FloatArray')
from rql.utils import register_function
from logilab.database import get_db_helper, FunctionDescr
from logilab.database.sqlgen import SQLExpression
register_base_type('IntArray', ('size',))
register_base_type('FloatArray')
pghelper = get_db_helper('postgres')
sqlitehelper = get_db_helper('sqlite')
def convert_array(values):
"""converter for Geometry"""
......@@ -17,10 +21,17 @@ def convert_array(values):
# Yams -> SQL type mapping
pghelper.TYPE_MAPPING['IntArray'] = 'integer[]'
pghelper.TYPE_MAPPING['FloatArray'] = 'double precision[]'
sqlitehelper.TYPE_MAPPING['IntArray'] = 'text'
sqlitehelper.TYPE_MAPPING['FloatArray'] = 'text'
# Python -> SQL conversion
pghelper.TYPE_CONVERTERS['IntArray'] = convert_array
pghelper.TYPE_CONVERTERS['FloatArray'] = convert_array
# NOTE: there's not way yet to specify the symmetrical operation
# (i.e. deserialization)
sqlitehelper.TYPE_CONVERTERS['IntArray'] = json.dumps
sqlitehelper.TYPE_CONVERTERS['FloatArray'] = json.dumps
## from cubicweb.schema import CONSTRAINTS
......
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