mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-23 17:13:10 +00:00
core: use strict tables (#6535)
* core: use strict tables * fix field types * change encodings to match schema types; migrate sqlite tables to strict mode * stabilize postgres client tests, remove slow handshake tests * update simplexmq * fix test * change call_state type to text * fix directory service queries * update local_alias for existing schemas * change types before strict
This commit is contained in:
1 parent
f0467aee00
commit
87e8a10f1e
19 files changed
+220
-121
No files matched your search
@@ -8389,7 +8389,7 @@ testChannelsRelayDeliver =
|
||||
createChannel5 :: TestCC -> TestCC -> TestCC -> TestCC -> TestCC -> GroupMemberRole -> IO ()
|
||||
createChannel5 alice bob cath dan eve mRole = do
|
||||
createGroup2 "team" alice bob
|
||||
bob ##> ("/create link #team " <> B.unpack (strEncode mRole))
|
||||
bob ##> ("/create link #team " <> T.unpack (textEncode mRole))
|
||||
gLink <- getGroupLink bob "team" mRole True
|
||||
cath ##> ("/c " <> gLink)
|
||||
cath <## "connection request sent!"
|
||||
|
||||
@@ -593,7 +593,7 @@ getGroupLink_ cc gName mRole created = do
|
||||
cc <## ""
|
||||
link <- getTermLine cc
|
||||
cc <## ""
|
||||
cc <## ("Anybody can connect to you and join group as " <> B.unpack (strEncode mRole) <> " with: /c <group_link_above>")
|
||||
cc <## ("Anybody can connect to you and join group as " <> T.unpack (textEncode mRole) <> " with: /c <group_link_above>")
|
||||
cc <## ("to show it again: /show link #" <> gName)
|
||||
cc <## ("to delete it: /delete link #" <> gName <> " (joined members will remain connected to you)")
|
||||
pure link
|
||||
@@ -809,12 +809,12 @@ fullAddMember :: HasCallStack => String -> String -> TestCC -> TestCC -> GroupMe
|
||||
fullAddMember gName fullName inviting invitee role = do
|
||||
name1 <- userName inviting
|
||||
memName <- userName invitee
|
||||
inviting ##> ("/a " <> gName <> " " <> memName <> " " <> B.unpack (strEncode role))
|
||||
inviting ##> ("/a " <> gName <> " " <> memName <> " " <> T.unpack (textEncode role))
|
||||
let fullName' = if null fullName || fullName == gName then "" else " (" <> fullName <> ")"
|
||||
concurrentlyN_
|
||||
[ inviting <## ("invitation to join the group #" <> gName <> " sent to " <> memName),
|
||||
do
|
||||
invitee <## ("#" <> gName <> fullName' <> ": " <> name1 <> " invites you to join the group as " <> B.unpack (strEncode role))
|
||||
invitee <## ("#" <> gName <> fullName' <> ": " <> name1 <> " invites you to join the group as " <> T.unpack (textEncode role))
|
||||
invitee <## ("use /j " <> gName <> " to accept")
|
||||
]
|
||||
|
||||
|
||||
+8
-1
@@ -17,7 +17,7 @@ import Data.Maybe (fromJust, isJust)
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.IO as T
|
||||
import Database.SQLite.Simple (Query (..))
|
||||
import Database.SQLite.Simple (Only (..), Query (..))
|
||||
import Simplex.Chat.Options.SQLite (chatDBFunctions)
|
||||
import Simplex.Chat.Store (createChatStore)
|
||||
import qualified Simplex.Chat.Store as Store
|
||||
@@ -59,6 +59,7 @@ schemaDumpTest = do
|
||||
it "verify and overwrite schema dump" testVerifySchemaDump
|
||||
it "verify .lint fkey-indexes" testVerifyLintFKeyIndexes
|
||||
it "verify schema down migrations" testSchemaMigrations
|
||||
it "verify strict tables" testVerifyStrict
|
||||
|
||||
testVerifySchemaDump :: IO ()
|
||||
testVerifySchemaDump = withTmpFiles $ do
|
||||
@@ -101,6 +102,12 @@ testSchemaMigrations = withTmpFiles $ do
|
||||
schema''' <- getSchema testDB testSchema
|
||||
schema''' `shouldBe` schema'
|
||||
|
||||
testVerifyStrict :: IO ()
|
||||
testVerifyStrict = do
|
||||
Right st <- createDBStore (DBOpts testDB chatDBFunctions "" False True TQOff) Store.migrations (MigrationConfig MCConsole Nothing)
|
||||
withConnection st (`DB.query_` "SELECT name FROM sqlite_master WHERE type = 'table' AND name != 'sqlite_sequence' AND sql NOT LIKE '% STRICT'")
|
||||
`shouldReturn` ([] :: [Only Text])
|
||||
|
||||
skipComparisonForUpMigrations :: [String]
|
||||
skipComparisonForUpMigrations =
|
||||
[ -- schema doesn't change
|
||||
|
||||
Reference in new issue
Block a user