generated from MasoniteFramework/starter-package
-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed models not loading their primary keys when updating
- Loading branch information
1 parent
724110f
commit bbba3f5
Showing
5 changed files
with
46 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import inspect | ||
import unittest | ||
|
||
from src.masoniteorm.query import QueryBuilder | ||
from src.masoniteorm.query.grammars import SQLiteGrammar | ||
from src.masoniteorm.connections import ConnectionFactory | ||
from src.masoniteorm.relationships import belongs_to | ||
from src.masoniteorm.models import Model | ||
from tests.utils import MockConnectionFactory | ||
from config.database import DATABASES | ||
|
||
|
||
class User(Model): | ||
__connection__ = "sqlite" | ||
__timestamps__ = False | ||
__dry__ = True | ||
|
||
|
||
class BaseTestQueryRelationships(unittest.TestCase): | ||
|
||
maxDiff = None | ||
|
||
def test_update_specific_record(self): | ||
user = User.first() | ||
sql = user.update({"name": "joe"}).to_sql() | ||
|
||
self.assertEqual( | ||
sql, | ||
"""UPDATE "users" SET "name" = 'joe' WHERE "id" = '{}'""".format(user.id), | ||
) | ||
|
||
def test_update_all_records(self): | ||
sql = User.update({"name": "joe"}).to_sql() | ||
|
||
self.assertEqual(sql, """UPDATE "users" SET "name" = 'joe'""") |