You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
data File = File {
fileName :: String
, filePath :: FilePath
, fileContents :: ByteString
}
$(deriveSafeCopy 0 'base ''File)
data Database = Database [File]
$(deriveSafeCopy 0 'base ''Database)
addFile :: File -> Update Database ()
addFile file = do
Database files <- get
put $ Database (file:files)
viewFiles :: Int -> Query Database [File]
viewFiles limit = do
Database files <- ask
return $ take limit files
$(makeAcidic ''Database ['addFile, 'viewFiles])
I did some tests and in one test I removed the fileName field. Then I ran a ViewFiles 10 query and no error showed up, but the resulting data was incorrect.
For example:
I inserted File "a" "b" "c" and after removing the field I got Field "a" "\NUL" back.
It was also possible to add new Files to the state. The new Files were ok when retrieved by a query. (A migration solved the problem too, of course).
Is this behavior intentional or a bug? I would expect an error, because the structure doesn't match the persisted structure.
The text was updated successfully, but these errors were encountered:
This is a limitation of the way SafeCopy is currently implemented. It is expected behavior -- but an error would be better. The short answer is "don't do that". The long answer is that it would be nice (for a variety of reasons) if acid-state/safecopy could produce a schema for the .log files.
Hi,
I have the following code:
I did some tests and in one test I removed the
fileName
field. Then I ran aViewFiles 10
query and no error showed up, but the resulting data was incorrect.For example:
I inserted
File "a" "b" "c"
and after removing the field I gotField "a" "\NUL"
back.It was also possible to add new
File
s to the state. The newFile
s were ok when retrieved by a query. (A migration solved the problem too, of course).Is this behavior intentional or a bug? I would expect an error, because the structure doesn't match the persisted structure.
The text was updated successfully, but these errors were encountered: