Comments (5)
I just released v0.5
which includes this change!
Literal
nodes now have a py_val
property, which is the closest Python equivalent of the OData type.
I refactored the existing Transformer
s to use this new property as well.
Note that release 0.5 also includes full typing support, so keep that in mind if you use Mypy and upgrade.
Thanks for suggesting this!
from odata-query.
Hey @keul ,
I think your example might be missing something as I don't see what you mean with SomethingElse
.
The parser will always output an AST
, and it's up to the ORM integration or a custom transormer to turn that into a usable query. So the Compare
node you see is exactly what I'd expect for that query.
from odata-query.
Really sorry @OliverHofkens, opened the issue while rushing (SomethingElse
was foo
).
My question was about doing this:
>>> odata_filter.right
Integer(val='15')
>>> odata_filter.right.val
'15'
There's not an (easy) way to obtain the Python value expected from this token (so the 15
integer value and not the '15'
str value).
I can obviously cast it myself by looking at the token type (Integer
in this case) but I'm wondering if there's a more straightforward way.
from odata-query.
Hey, no worries @keul, thanks for clarifying!
We could easily parse the values in Integer
s in the library. I think the only reason we didn't do this in the first place is because of consistency, as all other Token
values are str
as well. So if we're going to do this, I'd do this for all Token
at once (Integer
, Float
, Boolean
, Date
, Time
, DateTime
, and Duration
).
One thing we'd have to be absolutely sure about is that none of these casts result in data loss. The one that worries me most is Float
, as the str
value can hold arbitrary precise numbers while the Python float
suffers from the classic floating point imprecision problems.
A foolproof solution would be to just add a @property
to all Token
s that exposes the value as a Python built-in to end-users.
from odata-query.
Sure, I see the point!
Adding a new property getter with converted values would be great for a end-user point of view IMHO.
from odata-query.
Related Issues (20)
- Disambiguate single-item lists from parenthesized expressions.
- Fully type annotate the library HOT 2
- Better support for `ENUM`s HOT 1
- Does the parser support `contains(field, value)` comparisons? HOT 4
- Question about usage. HOT 2
- Outdated docs HOT 2
- Managing more than one entity in `AstToSqlAlchemyClauseVisitor` HOT 3
- Filter not working for uuid column HOT 6
- Remove Athena specific code HOT 3
- Support for SQLAlchemy Core HOT 2
- Support relationship traversal and `any/all` in SQLAlchemy Core
- Implicit Support for SQLAlchemy's Query-API has been removed HOT 5
- Filter on joined relationship not working for legacy Query objects HOT 3
- apply aggregation support HOT 2
- Definition of sqlalchemy functions_ext overrides desired behaviour HOT 2
- Question about integration HOT 1
- `AstToSqlVisitor` can not handle a function call as right hand side of contains-filter HOT 2
- odata geospatial properties HOT 3
- Missing release tags HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odata-query.