We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug If you have decimal migrations then you can't return response.
Migration
def up(self): """ Run the migrations. """ with self.schema.create("commerce_products") as table: table.increments("id") table.string("title") table.string("slug").unique() table.decimal("price", 19, 2) table.timestamps()
Modal
class Product(Model): __fillable__ = ["title", "slug", "price"]
Controller
class ProductController(Controller): def __init__(self, response: Response, request: Request) -> None: self.response = response self.request = request def index(self): """Returns a list of products""" per_page = int(self.request.input("per-page", 10)) page = int(self.request.input("page", 1)) return Product.paginate(per_page, page)
Expected behavior I should see a proper json response
Screenshots or code snippets
The text was updated successfully, but these errors were encountered:
The fix to this is to cast the decimal to a float in the model:
class CommerceProducts(Model): __casts__ = { "price": "float" }
Sorry, something went wrong.
No branches or pull requests
Describe the bug
If you have decimal migrations then you can't return response.
Migration
Modal
Controller
Expected behavior
I should see a proper json response
Screenshots or code snippets
The text was updated successfully, but these errors were encountered: