fernandojunior/python-sqlite-orm

[Feature] Validate correct type affinity before inserting or updating records

Closed this issue · 0 comments

Problem:

Currently, records can be inserted and updated with incorrect type. While columns in sqlite have type affinity, they don't strictly enforce it.

Example

Model:

from orm import Model

class Post(Model):

    random = float
    text = str

    def __init__(self, text):
        self.text = text
        self.random = random()`

Currently Valid Query

Successfully inserting a new Post into the database where the value for text does not match the column type:

from orm import Database

db = Database('db.sqlite')
Post.db = db

post = Post(text = 12.3).save()