diff --git a/src/masoniteorm/commands/MigrateStatusCommand.py b/src/masoniteorm/commands/MigrateStatusCommand.py index ea95e7ff..7ddbfdd3 100644 --- a/src/masoniteorm/commands/MigrateStatusCommand.py +++ b/src/masoniteorm/commands/MigrateStatusCommand.py @@ -30,12 +30,20 @@ def handle(self): batch = migration_data["batch"] migrations.append( - ["Y", f"{migration_file}", f"{batch}"] + [ + "Y", + f"{migration_file}", + f"{batch}", + ] ) for migration_file in migration.get_unran_migrations(): migrations.append( - ["N", f"{migration_file}", "-"] + [ + "N", + f"{migration_file}", + "-", + ] ) table.set_rows(migrations) diff --git a/src/masoniteorm/query/QueryBuilder.py b/src/masoniteorm/query/QueryBuilder.py index 07acade8..3a45a614 100644 --- a/src/masoniteorm/query/QueryBuilder.py +++ b/src/masoniteorm/query/QueryBuilder.py @@ -9,7 +9,8 @@ HTTP404, ConnectionNotRegistered, ModelNotFound, - MultipleRecordsFound, InvalidArgument, + MultipleRecordsFound, + InvalidArgument, ) from ..expressions.expressions import ( AggregateExpression, @@ -47,7 +48,7 @@ def __init__( scopes=None, schema=None, dry=False, - config_path=None + config_path=None, ): """QueryBuilder initializer diff --git a/src/masoniteorm/schema/Schema.py b/src/masoniteorm/schema/Schema.py index e7bebc9d..af1a17c3 100644 --- a/src/masoniteorm/schema/Schema.py +++ b/src/masoniteorm/schema/Schema.py @@ -57,7 +57,7 @@ def __init__( grammar=None, connection_details=None, schema=None, - config_path=None + config_path=None, ): self._dry = dry self.connection = connection @@ -306,11 +306,7 @@ def get_all_tables(self): result = self.new_connection().query(sql, ()) - return ( - list(map(lambda t: list(t.values())[0], result)) - if result - else [] - ) + return list(map(lambda t: list(t.values())[0], result)) if result else [] def has_table(self, table, query_only=False): """Checks if the a database has a specific table diff --git a/tests/models/test_models.py b/tests/models/test_models.py index a473224c..520244fc 100644 --- a/tests/models/test_models.py +++ b/tests/models/test_models.py @@ -19,30 +19,17 @@ class ModelTest(Model): class FillableModelTest(Model): - __fillable__ = [ - "due_date", - "is_vip", - ] + __fillable__ = ["due_date", "is_vip"] class InvalidFillableGuardedModelTest(Model): - __fillable__ = [ - "due_date", - ] - __guarded__ = [ - "is_vip", - "payload", - ] + __fillable__ = ["due_date"] + __guarded__ = ["is_vip", "payload"] class InvalidFillableGuardedChildModelTest(ModelTest): - __fillable__ = [ - "due_date", - ] - __guarded__ = [ - "is_vip", - "payload", - ] + __fillable__ = ["due_date"] + __guarded__ = ["is_vip", "payload"] class ModelTestForced(Model): @@ -147,9 +134,7 @@ def test_model_can_cast_dict_attributes(self): def test_valid_json_cast(self): model = ModelTest.hydrate( - { - "payload": {"this": "dict", "is": "usable", "as": "json"}, - } + {"payload": {"this": "dict", "is": "usable", "as": "json"}} ) self.assertEqual(type(model.payload), dict) diff --git a/tests/mysql/model/test_model.py b/tests/mysql/model/test_model.py index 6bc7623d..99fd1ef8 100644 --- a/tests/mysql/model/test_model.py +++ b/tests/mysql/model/test_model.py @@ -113,10 +113,7 @@ def test_create_can_use_guarded_asterisk(self): # An asterisk guarded attribute excludes all fields from mass-assignment. # This would raise a DB error if there are any required fields. - self.assertEqual( - sql, - "INSERT INTO `profiles` (*) VALUES ()", - ) + self.assertEqual(sql, "INSERT INTO `profiles` (*) VALUES ()") def test_bulk_create_can_use_fillable(self): query_builder = ProfileFillable.bulk_create( @@ -173,8 +170,7 @@ def test_bulk_create_can_use_guarded_asterisk(self): # This would obviously raise an invalid SQL syntax error. # TODO: Raise a clearer error? self.assertEqual( - query_builder.to_sql(), - "INSERT INTO `profiles` () VALUES (), ()", + query_builder.to_sql(), "INSERT INTO `profiles` () VALUES (), ()" ) def test_update_can_use_fillable(self): @@ -214,10 +210,7 @@ def test_update_can_use_guarded_asterisk(self): # An asterisk guarded attribute excludes all fields from mass-assignment. # The query builder's sql should not have been altered in any way. - self.assertEqual( - query_builder.to_sql(), - initial_sql, - ) + self.assertEqual(query_builder.to_sql(), initial_sql) def test_table_name(self): table_name = Profile.get_table_name() @@ -250,12 +243,7 @@ def test_serialize_with_hidden(self): def test_serialize_with_visible(self): profile = ProfileSerializeWithVisible.hydrate( - { - "name": "Joe", - "id": 1, - "password": "secret", - "email": "joe@masonite.com", - } + {"name": "Joe", "id": 1, "password": "secret", "email": "joe@masonite.com"} ) self.assertTrue( {"name": "Joe", "email": "joe@masonite.com"}, profile.serialize() @@ -263,12 +251,7 @@ def test_serialize_with_visible(self): def test_serialize_with_visible_and_hidden_raise_error(self): profile = ProfileSerializeWithVisibleAndHidden.hydrate( - { - "name": "Joe", - "id": 1, - "password": "secret", - "email": "joe@masonite.com", - } + {"name": "Joe", "id": 1, "password": "secret", "email": "joe@masonite.com"} ) with self.assertRaises(AttributeError): profile.serialize() diff --git a/tests/sqlite/models/test_sqlite_model.py b/tests/sqlite/models/test_sqlite_model.py index 3a30e4a9..c833c113 100644 --- a/tests/sqlite/models/test_sqlite_model.py +++ b/tests/sqlite/models/test_sqlite_model.py @@ -87,17 +87,13 @@ def test_find_or_if_record_not_found(self): record_id = 1_000_000_000_000_000 result = User.find_or(record_id, lambda: "Record not found.") - self.assertEqual( - result, "Record not found." - ) + self.assertEqual(result, "Record not found.") def test_find_or_if_record_found(self): record_id = 1 result_id = User.find_or(record_id, lambda: "Record not found.").id - self.assertEqual( - result_id, record_id - ) + self.assertEqual(result_id, record_id) def test_can_set_and_retreive_attribute(self): user = User.hydrate({"id": 1, "name": "joe", "customer_id": 1})