Skip to content

Experimental query builder #1161

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

Open
RogerSelwyn opened this issue Apr 22, 2025 · 4 comments
Open

Experimental query builder #1161

RogerSelwyn opened this issue Apr 22, 2025 · 4 comments

Comments

@RogerSelwyn
Copy link
Contributor

RogerSelwyn commented Apr 22, 2025

Opening this thread to separate from other items.

Running this code results in the error shown below:

builder = ExperimentalQuery(protocol=account.protocol)
schedule = account.schedule()
calendars = schedule.list_calendars()
calendar = calendars[1]
query = builder.select(
    "subject",
    "body",
)
start = datetime.now()
end = datetime.now() + timedelta(weeks=1)

query = query & (builder.greater_equal("start", start) & builder.less_equal("ent", end))

events = calendar.get_events(query=query)
Exception has occurred: AttributeError
'CompositeFilter' object has no attribute '_filters'
  File "/HADev/Hassio/dev-config/O365/calendar.py", line 1799, in get_events
    for query_data in query._filters:
                      ^^^^^^^^^^^^^^
  File "/HADev/Hassio/dev-config/bash_o365_query.py", line 57, in <module>
    events = calendar.get_events(query=query)
AttributeError: 'CompositeFilter' object has no attribute '_filters'

Calendar shouldn't really be accessing _filters, but it is using it to extract start and end date. Can't easily see the resolution.

@RogerSelwyn
Copy link
Contributor Author

I've used a number of other methods in the query builder, which have all worked. Not tried everything though.

@alejcas
Copy link
Member

alejcas commented Apr 22, 2025

Wow! didn't remember that... Thanks for the finding!
I'll look into this and try to solve it

@RogerSelwyn
Copy link
Contributor Author

Wow! didn't remember that... Thanks for the finding! I'll look into this and try to solve it

Probably ought to be extracting them from the query more directly in get_events, or provide a method on query to pop them. But it needs to be backward compatible to allow a migration.

@alejcas
Copy link
Member

alejcas commented Apr 22, 2025

Wow! didn't remember that... Thanks for the finding! I'll look into this and try to solve it

Probably ought to be extracting them from the query more directly in get_events, or provide a method on query to pop them. But it needs to be backward compatible to allow a migration.

I know to fix it.
But I will have to change Calendar.get_events and both ExperimentalQuery and the old query for users to be able to work with both.
So users will be able to use one or another on the next version.

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

No branches or pull requests

2 participants