atviriduomenys / spinta

Spinta is a framework to describe, extract and publish data (a DEP Framework).
MIT License
10 stars 4 forks source link

Fix _id.contains on ref type #538

Open sirex opened 7 months ago

sirex commented 7 months ago

Example: https://get.data.gov.lt/datasets/gov/vmi/ja_mokesciai/Moketojas?mm_kodas._id.contains(%22732f1021-d05c-419d-97bb-677d2a005d3d%22)

This gives

Traceback (most recent call last):
  File "spinta/api.py", line 95, in homepage
    return await create_http_response(context, params, request)
  File "spinta/utils/response.py", line 162, in create_http_response
    return await commands.getall(
  File "spinta/commands/read.py", line 125, in getall
    return render(context, request, model, params, rows, action=action)
  File "spinta/renderer.py", line 23, in render
    return commands.render(
  File "spinta/formats/html/commands.py", line 139, in render
    return _render_model(context, request, model, action, params, data, headers)
  File "spinta/formats/html/commands.py", line 243, in _render_model
    ctx = build_template_context(
  File "spinta/formats/html/commands.py", line 217, in build_template_context
    rows, empty = _is_empty(rows)
  File "spinta/formats/html/commands.py", line 171, in _is_empty
    row = next(rows)
  File "spinta/utils/nestedstruct.py", line 15, in flatten
    for v in vals:
  File "spinta/commands/read.py", line 110, in <genexpr>
    rows = (
  File "spinta/backends/postgresql/commands/read.py", line 51, in getall
    expr = env.resolve(query)
  File "spinta/core/ufuncs.py", line 242, in resolve
    return ufunc(self, expr)
  File "spinta/backends/postgresql/commands/query.py", line 440, in and_
    args, kwargs = expr.resolve(env)
  File "spinta/core/ufuncs.py", line 61, in resolve
    arg = env.resolve(arg)
  File "spinta/core/ufuncs.py", line 236, in resolve
    return ufunc(self, *args, **kwargs)
  File "spinta/core/ufuncs.py", line 165, in wrapper
    return func(env, name, *args, **kwargs)
  File "spinta/backends/postgresql/commands/query.py", line 521, in compare
    return env.call(op, fpr, fpr.right.dtype, value)
  File "spinta/core/ufuncs.py", line 216, in call
    return ufunc(self, *args, **kwargs)
  File "spinta/core/ufuncs.py", line 165, in wrapper
    return func(env, name, *args, **kwargs)
  File "spinta/backends/postgresql/commands/query.py", line 516, in compare
    raise exceptions.InvalidValue(dtype, op=op, arg=type(value).__name__)
spinta.exceptions.InvalidValue: Invalid value.
  Context:
    component: spinta.types.datatype.PrimaryKey
    manifest: default
    schema: 13405
    dataset: datasets/gov/vmi/mm_registras
    model: datasets/gov/vmi/mm_registras/MokesciuMoketojas
    entity:
    property: _id
    attribute: None
    type: pk
    op: contains
    arg: str