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

Bug: sorting by datetime does not work #563

Open
Kaiden0001 opened this issue Jul 17, 2024 · 0 comments
Open

Bug: sorting by datetime does not work #563

Kaiden0001 opened this issue Jul 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Kaiden0001
Copy link

Kaiden0001 commented Jul 17, 2024

hi
postgres+asyncpg
starlette-admin==0.13.2
models.py

class Log(Base):
    created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
    ...
 2024-07-17 12:25:35.227 UTC [4632] ERROR:  operator does not exist: timestamp with time zone >= character varying at character 156
 2024-07-17 12:25:35.227 UTC [4632] HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
 2024-07-17 12:25:35.227 UTC [4632] STATEMENT:  SELECT logs.url, logs.endpoint, logs.created_at, logs.status_code, logs.content_length, logs.api_key, logs.body, logs.id 
     FROM logs 
     WHERE logs.created_at BETWEEN $1::VARCHAR AND $2::VARCHAR ORDER BY logs.created_at DESC 
      LIMIT $3::INTEGER OFFSET $4::INTEGER
 (sqlalchemy.dialects.postgresql.asyncpg.ProgrammingError) <class 'asyncpg.exceptions.UndefinedFunctionError'>: operator does not exist: timestamp with time zone >= character varying
 HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
 [SQL: SELECT logs.url, logs.endpoint, logs.created_at, logs.status_code, logs.content_length, logs.api_key, logs.body, logs.id 
 FROM logs 
 WHERE logs.created_at BETWEEN $1::VARCHAR AND $2::VARCHAR ORDER BY logs.created_at DESC 
  LIMIT $3::INTEGER OFFSET $4::INTEGER]
 [parameters: ('2024-07-17T15:25:00+03:00', '2024-07-18T15:25:00+03:00', 100, 0)]
 (Background on this error at: https://sqlalche.me/e/20/f405)
 2024-07-17 12:25:35.229 UTC [4632] ERROR:  current transaction is aborted, commands ignored until end of transaction block
 2024-07-17 12:25:35.229 UTC [4632] STATEMENT:  SELECT logs.url, logs.endpoint, logs.created_at, logs.status_code, logs.content_length, logs.api_key, logs.body, logs.id 
     FROM logs 
     WHERE logs.created_at BETWEEN $1::VARCHAR AND $2::VARCHAR ORDER BY logs.created_at DESC 
      LIMIT $3::INTEGER OFFSET $4::INTEGER
 INFO:     172.21.0.1:51892 - "GET /admin/api/log?skip=0&limit=100&order_by=created_at%20desc&where=%7B%22and%22%3A%5B%7B%22created_at%22%3A%7B%22between%22%3A%5B%222024-07-17T15%3A25%3A00%2B03%3A00%22%2C%222024-07-18T15%3A25%3A00%2B03%3A00%22%5D%7D%7D%5D%7D HTTP/1.1" 500 Internal Server Error

how do I fix it?

@Kaiden0001 Kaiden0001 added the bug Something isn't working label Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant