Skip to content

Commit

Permalink
fixed model fillable
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso committed Jan 30, 2021
1 parent 00c8cb4 commit 64a43e2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion src/masoniteorm/models/Model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__:
Expand Down
5 changes: 3 additions & 2 deletions tests/postgres/schema/test_postgres_schema_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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, "
Expand Down

0 comments on commit 64a43e2

Please sign in to comment.