Skip to content

Commit 4c9db33

Browse files
committed
support for full text catalogs
1 parent b77b30b commit 4c9db33

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

src/Database/SqlServer/Types/Database.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Database.SqlServer.Types.Queue (QueueDefinition)
1010
import Database.SqlServer.Types.Certificate (CertificateDefinition)
1111
import Database.SqlServer.Types.Login (LoginDefinition)
1212
import Database.SqlServer.Types.User (UserDefinition)
13+
import Database.SqlServer.Types.FullTextCatalog (FullTextCatalogDefinition)
1314
import Database.SqlServer.Types.Entity
1415

1516
import Test.QuickCheck
@@ -24,7 +25,7 @@ data MasterKey = MasterKey
2425
derive makeArbitrary ''MasterKey
2526

2627
instance Entity MasterKey where
27-
toDoc MasterKey = text "CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'arbitrary_password'" $+$
28+
toDoc MasterKey = text "CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'weKKjwehg252t!!'" $+$
2829
text "GO"
2930

3031
data DatabaseDefinition = DatabaseDefinition
@@ -37,6 +38,7 @@ data DatabaseDefinition = DatabaseDefinition
3738
, certificateDefinitions :: [CertificateDefinition]
3839
, userDefinitions :: [UserDefinition]
3940
, loginDefinitions :: [LoginDefinition]
41+
, fullTextCatalogDefinitions :: [FullTextCatalogDefinition]
4042
, masterKey :: MasterKey
4143
}
4244

@@ -57,6 +59,7 @@ renderDatabaseDefinition dd = text "USE master" $+$
5759
renderNamedEntities (certificateDefinitions dd) $+$
5860
renderNamedEntities (userDefinitions dd) $+$
5961
renderNamedEntities (loginDefinitions dd) $+$
62+
renderNamedEntities (fullTextCatalogDefinitions dd) $+$
6063
text "GO"
6164
where
6265
dbName = renderRegularIdentifier (databaseName dd)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{-# LANGUAGE DeriveGeneric #-}
2+
{-# LANGUAGE TemplateHaskell #-}
3+
4+
module Database.SqlServer.Types.FullTextCatalog where
5+
6+
import Database.SqlServer.Types.Identifiers
7+
import Database.SqlServer.Types.Entity
8+
9+
import Test.QuickCheck
10+
import Text.PrettyPrint
11+
import Data.DeriveTH
12+
13+
data FullTextCatalogDefinition = FullTextCatalogDefinition
14+
{
15+
catalogName :: RegularIdentifier
16+
, filegroup :: Maybe RegularIdentifier
17+
, accentSensitive :: Maybe Bool
18+
, asDefault :: Bool
19+
-- TODO ignore users
20+
}
21+
22+
derive makeArbitrary ''FullTextCatalogDefinition
23+
24+
renderFileGroup :: RegularIdentifier -> Doc
25+
renderFileGroup n = text "ON FILEGROUP" <+> (renderRegularIdentifier n)
26+
27+
renderOptions :: Bool -> Doc
28+
renderOptions True = text "WITH ACCENT_SENSITIVITY = ON"
29+
renderOptions False = text "WITH ACCENT_SENSITIVITY = OFF"
30+
31+
instance Entity FullTextCatalogDefinition where
32+
toDoc ftc = text "CREATE FULLTEXT CATALOG" <+>
33+
renderRegularIdentifier (catalogName ftc) $+$
34+
maybe empty renderFileGroup (filegroup ftc) $+$
35+
maybe empty renderOptions (accentSensitive ftc) $+$
36+
if (asDefault ftc) then text "AS DEFAULT" else empty $+$
37+
text "GO\n"

0 commit comments

Comments
 (0)