From 64a43e26714552f0e831a96214d37669111ebf40 Mon Sep 17 00:00:00 2001 From: Joe Mancuso Date: Sat, 30 Jan 2021 11:37:15 -0500 Subject: [PATCH] fixed model fillable --- setup.py | 2 +- src/masoniteorm/models/Model.py | 4 +++- tests/postgres/schema/test_postgres_schema_builder.py | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 73bef208..5faebafc 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # https://packaging.python.org/en/latest/single_source_version.html - version="1.0.16", + version="1.0.17", package_dir={"": "src"}, description="The Official Masonite ORM", long_description=long_description, diff --git a/src/masoniteorm/models/Model.py b/src/masoniteorm/models/Model.py index 92e3ff38..0ebb8ce4 100644 --- a/src/masoniteorm/models/Model.py +++ b/src/masoniteorm/models/Model.py @@ -351,9 +351,11 @@ def create(cls, dictionary=None, query=False, **kwargs): dictionary = kwargs if cls.__fillable__ != ["*"]: + d = {} for x in cls.__fillable__: if x in dictionary: - dictionary.update({x: dictionary[x]}) + d.update({x: dictionary[x]}) + dictionary = d if cls.__guarded__ != ["*"]: for x in cls.__guarded__: diff --git a/tests/postgres/schema/test_postgres_schema_builder.py b/tests/postgres/schema/test_postgres_schema_builder.py index 7444817b..8cb0e4ff 100644 --- a/tests/postgres/schema/test_postgres_schema_builder.py +++ b/tests/postgres/schema/test_postgres_schema_builder.py @@ -114,6 +114,7 @@ def test_can_advanced_table_creation2(self): blueprint.string("duration") blueprint.decimal("money") blueprint.string("url") + blueprint.string("option").default("ADMIN") blueprint.jsonb("payload") blueprint.datetime("published_at") blueprint.string("thumbnail").nullable() @@ -125,12 +126,12 @@ def test_can_advanced_table_creation2(self): blueprint.text("description") blueprint.timestamps() - self.assertEqual(len(blueprint.table.added_columns), 13) + self.assertEqual(len(blueprint.table.added_columns), 14) self.assertEqual( blueprint.to_sql(), ( 'CREATE TABLE "users" (id SERIAL UNIQUE NOT NULL, name VARCHAR(255) NOT NULL, ' - "duration VARCHAR(255) NOT NULL, money DECIMAL(17, 6) NOT NULL, url VARCHAR(255) NOT NULL, payload JSONB NOT NULL, published_at TIMESTAMP NOT NULL, " + "duration VARCHAR(255) NOT NULL, money DECIMAL(17, 6) NOT NULL, url VARCHAR(255) NOT NULL, option VARCHAR(255) NOT NULL DEFAULT 'ADMIN', payload JSONB NOT NULL, published_at TIMESTAMP NOT NULL, " "thumbnail VARCHAR(255) NULL, premium INTEGER NOT NULL, author_id INT NULL, " "description TEXT NOT NULL, created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, " "updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, "