Numeric Fields — Aquilia Documentation
Comprehensive guide and documentation for Numeric Fields in the Aquilia framework. View API reference, examples, and implementation patterns.
Docs / Models / Numeric Fields Numeric Fields Aquilia provides a set of typed numeric fields representing integer, float, and decimal types. They are strictly typed and reject invalid coercions. IntegerField Types All integer fields map to standard SQL column sizes. Note that booleans are strictly rejected. Field Python Type SQL (Postgres) Range ))} Float & Decimal Fields FloatField Maps to REAL or DOUBLE PRECISION in database. score = FloatField(null=True) DecimalField Precision decimal fields. Requires max_digits and decimal_places. Maps to DECIMAL(m, d). price = DecimalField(max_digits=10, decimal_places=2) MoneyField A DecimalField subclass that adds a currency code. Same precision-safe storage as DecimalField (stored as str(), never a binary float) — the currency is metadata carried on the field, not encoded per-row. total = MoneyField(max_digits=12, decimal_places=2, currency="USD") order = await Order.create(total="149.99") order.total # Decimal('149.99') currency only validates the 3-uppercase-letter shape (not a full ISO 4217 lookup table) — a well-formed but unrecognized code is accepted on purpose: MoneyField(currency="dollars") # raises FieldValidationError immediately Auto Incremented Primary Keys Use AutoField or BigAutoField for auto-increment keys: class User(Model): # BigAutoField is default if id is omitted id = BigAutoField(primary_key=True) Fields Overview Text Fields )
Go to Homepage