Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
array
Commits
43e2135ec62f
Commit
16079709
authored
Apr 23, 2013
by
Vincent Michel
Browse files
[schema] Add array type
parent
f079faabc271
Changes
2
Hide whitespace changes
Inline
Side-by-side
ccplugin.py
0 → 100644
View file @
43e2135e
from
yams
import
register_base_type
register_base_type
(
'IntArray'
)
register_base_type
(
'FloatArray'
)
# 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
schema.py
View file @
43e2135e
...
...
@@ -15,4 +15,7 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-array schema"""
"""cubicweb-postgres-array schema"""
from
yams.buildobjs
import
_make_type
IntArray
=
_make_type
(
'IntArray'
)
FloatArray
=
_make_type
(
'FloatArray'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment