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

Support Ecto DSL in enable_hypertable_compression/2 #4

Open
davydog187 opened this issue Aug 20, 2022 · 4 comments
Open

Support Ecto DSL in enable_hypertable_compression/2 #4

davydog187 opened this issue Aug 20, 2022 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@davydog187
Copy link
Owner

We have a function enable_hypertable_compression/2 which corresponds to an alter table, see the timescale docs

Currently we're only allowing you to pass the column name, but we should support the order and nulls rules as well. See below 👇🏼

ALTER TABLE <table_name> SET (timescaledb.compress, timescaledb.compress_orderby = '<column_name> [ASC | DESC] [ NULLS { FIRST | LAST } ] [, ...]',
timescaledb.compress_segmentby = '<column_name> [, ...]'
);
@davydog187 davydog187 added enhancement New feature or request help wanted Extra attention is needed labels Aug 20, 2022
@doomspork
Copy link
Collaborator

I'm trying to better understand how you want the Ecto DSL to play into this. Do you have an idea of what you sort of see the final product looking like?

enable_hypertable_compression(:prices, 
  segment_by: "currency_id", 
  order_by: [asc: :inserted_at, desc_nulls_first: :another_id]
)

@davydog187
Copy link
Owner Author

Your example is on the money. On my phone, but I believe there are some alternative ways to do that, we should support them as well

@davydog187
Copy link
Owner Author

From the Ecto.Query.order_by/3 documentation, we should support the following examples:

from(c in City, order_by: c.name, order_by: c.population)
from(c in City, order_by: [c.name, c.population])
from(c in City, order_by: [asc: c.name, desc: c.population])

from(c in City, order_by: [:name, :population])
from(c in City, order_by: [asc: :name, desc_nulls_first: :population])

@akoutmos
Copy link
Collaborator

Adding as a note here that this issue should also address the SQL injection issues mentioned in #11

@davydog187 davydog187 added this to the First stable release milestone Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants