Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sqlite: StructuredTest returns string instead of json object? #150

Open
RAbraham opened this issue Jul 23, 2021 · 2 comments
Open

Sqlite: StructuredTest returns string instead of json object? #150

RAbraham opened this issue Jul 23, 2021 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@RAbraham
Copy link
Contributor

%%logica StructureTest
@Engine("sqlite");
StructureTest(a: {x: 1, y: 2, z: { w: "hello", v: "world"}});
StructureTest(a: {x: 3, y: 4, z: { w: "bonjour", v: "monde"}});
print(StructureTest['a'].values[0])
print(type(StructureTest['a'].values[0]))
print(StructureTest['a'].values[0]['z']['w']) # <===== This is the line in the tutorial that fails
{"x":1,"y":2,"z":{"w":"hello","v":"world"}}
<class 'str'>

---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)

<ipython-input-14-dbaa4016c4ed> in <module>()
      2 print(StructureTest['a'].values[0])
      3 print(type(StructureTest['a'].values[0]))
----> 4 print(StructureTest['a'].values[0]['z']['w'])

TypeError: string indices must be integers
@EvgSkv
Copy link
Owner

EvgSkv commented Jul 28, 2021

Yes, that's right. I'm afraid it will have to stay this way for a while.
SQLite treats jsons as strings and there is no robust way to differentiate string from object.

We will need to explain it in documentation though.

@EvgSkv EvgSkv added the documentation Improvements or additions to documentation label Jul 28, 2021
@RAbraham
Copy link
Contributor Author

RAbraham commented Aug 4, 2021

👍 please close at will.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants