25 |
25 |
26 from logilab.common.shellutils import ProgressBar |
26 from logilab.common.shellutils import ProgressBar |
27 |
27 |
28 from yams import BadSchemaDefinition, schema as schemamod, buildobjs as ybo |
28 from yams import BadSchemaDefinition, schema as schemamod, buildobjs as ybo |
29 |
29 |
30 from cubicweb import CW_SOFTWARE_ROOT, Binary |
30 from cubicweb import CW_SOFTWARE_ROOT, Binary, typed_eid |
31 from cubicweb.schema import (KNOWN_RPROPERTIES, CONSTRAINTS, ETYPE_NAME_MAP, |
31 from cubicweb.schema import (KNOWN_RPROPERTIES, CONSTRAINTS, ETYPE_NAME_MAP, |
32 VIRTUAL_RTYPES, PURE_VIRTUAL_RTYPES) |
32 VIRTUAL_RTYPES, PURE_VIRTUAL_RTYPES) |
33 from cubicweb.server import sqlutils |
33 from cubicweb.server import sqlutils |
34 |
34 |
35 |
35 |
210 'X fulltextindexed FTIDX, X from_entity SE, X to_entity OE', |
210 'X fulltextindexed FTIDX, X from_entity SE, X to_entity OE', |
211 build_descr=False): |
211 build_descr=False): |
212 rdefeid, seid, reid, oeid, card, ord, desc, idx, ftidx, i18n, default = values |
212 rdefeid, seid, reid, oeid, card, ord, desc, idx, ftidx, i18n, default = values |
213 typeparams = extra_props.get(rdefeid) |
213 typeparams = extra_props.get(rdefeid) |
214 typeparams = json.load(typeparams) if typeparams else {} |
214 typeparams = json.load(typeparams) if typeparams else {} |
|
215 if default is not None: |
|
216 if isinstance(default, Binary): |
|
217 # while migrating from 3.17 to 3.18, we still have to |
|
218 # handle String defaults |
|
219 default = default.unzpickle() |
215 _add_rdef(rdefeid, seid, reid, oeid, |
220 _add_rdef(rdefeid, seid, reid, oeid, |
216 cardinality=card, description=desc, order=ord, |
221 cardinality=card, description=desc, order=ord, |
217 indexed=idx, fulltextindexed=ftidx, internationalizable=i18n, |
222 indexed=idx, fulltextindexed=ftidx, internationalizable=i18n, |
218 default=default, **typeparams) |
223 default=default, **typeparams) |
219 for values in session.execute( |
224 for values in session.execute( |
525 elif prop == 'ordernum': |
530 elif prop == 'ordernum': |
526 value = int(value) |
531 value = int(value) |
527 elif isinstance(value, str): |
532 elif isinstance(value, str): |
528 value = unicode(value) |
533 value = unicode(value) |
529 if value is not None and prop == 'default': |
534 if value is not None and prop == 'default': |
530 if value is False: |
535 value = Binary.zpickle(value) |
531 value = u'' |
|
532 if not isinstance(value, unicode): |
|
533 value = unicode(value) |
|
534 values[amap.get(prop, prop)] = value |
536 values[amap.get(prop, prop)] = value |
535 if extra: |
537 if extra: |
536 values['extra_props'] = Binary(json.dumps(extra)) |
538 values['extra_props'] = Binary(json.dumps(extra)) |
537 relations = ['X %s %%(%s)s' % (attr, attr) for attr in sorted(values)] |
539 relations = ['X %s %%(%s)s' % (attr, attr) for attr in sorted(values)] |
538 return relations, values |
540 return relations, values |