Commit 16079709 authored by Vincent Michel's avatar Vincent Michel
Browse files

[schema] Add array type

parent f079faabc271
from yams import register_base_type
# Add a converter for Geometry
from logilab.database.sqlgen import SQLExpression
def convert_array(values):
return SQLExpression('ARRAY[%s]' % ', '.join([str(x) for x in values]))
# Add the datatype to the helper mapping
from logilab.database import get_db_helper
# Add the datatype to the helper mapping
helper = get_db_helper('postgres')
typemap = helper.TYPE_MAPPING
typemap['IntArray'] = 'integer[]'
typemap['FloatArray'] = 'double[]'
# Add the converter function to the known SQL_CONVERTERS
helper.TYPE_CONVERTERS['IntArray'] = convert_array
helper.TYPE_CONVERTERS['FloatArray'] = convert_array
......@@ -15,4 +15,7 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <>.
"""cubicweb-array schema"""
"""cubicweb-postgres-array schema"""
from yams.buildobjs import _make_type
IntArray = _make_type('IntArray')
FloatArray = _make_type('FloatArray')
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