@@ -158,7 +158,10 @@ dbClient.transaction { db =>
158158 sql " INSERT INTO buyer (name, date_of_birth) VALUES ( $newName, $newDateOfBirth), ( $newName, $newDateOfBirth) "
159159 )
160160
161- assert(generatedIds == Seq (4 , 5 ))
161+ if (! this .isInstanceOf [MsSqlSuite ])
162+ assert(generatedIds == Seq (4 , 5 ))
163+ else
164+ assert(generatedIds == Seq (5 ))
162165
163166 db.run(Buyer .select) ==> List (
164167 Buyer [Sc ](1 , " James Bond" , LocalDate .parse(" 2001-02-03" )),
@@ -236,7 +239,10 @@ dbClient.transaction { db =>
236239 LocalDate .parse(" 2000-01-01" )
237240 )
238241 )
239- assert(generatedKeys == Seq (4 , 5 ))
242+ if (! this .isInstanceOf [MsSqlSuite ])
243+ assert(generatedKeys == Seq (4 , 5 ))
244+ else
245+ assert(generatedKeys == Seq (5 ))
240246
241247 db.run(Buyer .select) ==> List (
242248 Buyer [Sc ](1 , " James Bond" , LocalDate .parse(" 2001-02-03" )),
@@ -1997,7 +2003,6 @@ Buyer.select
19972003 .leftJoin(ShippingInfo)(_.id `=` _.buyerId)
19982004 .map { case (b, si) => (b.name, si.map(_.shippingDate)) }
19992005 .sortBy(_._2)
2000- .nullsFirst
20012006```
20022007
20032008
@@ -2006,7 +2011,7 @@ Buyer.select
20062011 SELECT buyer0.name AS res_0, shipping_info1.shipping_date AS res_1
20072012 FROM buyer buyer0
20082013 LEFT JOIN shipping_info shipping_info1 ON (buyer0.id = shipping_info1.buyer_id)
2009- ORDER BY res_1 NULLS FIRST
2014+ ORDER BY res_1
20102015 ```
20112016
20122017
@@ -3395,7 +3400,7 @@ Purchase.delete(_ => true)
33953400
33963401*
33973402 ```sql
3398- DELETE FROM purchase WHERE ?
3403+ DELETE FROM purchase
33993404 ```
34003405
34013406
@@ -4003,7 +4008,7 @@ Product.select
40034008
40044009
40054010## UpdateJoin
4006- `UPDATE` queries that use `JOIN`s
4011+ Basic `UPDATE` queries
40074012### UpdateJoin.join
40084013
40094014ScalaSql supports performing `UPDATE`s with `FROM`/`JOIN` clauses using the
@@ -6951,7 +6956,7 @@ Select.delete(_ => true)
69516956
69526957*
69536958 ```sql
6954- DELETE FROM "select" WHERE ?
6959+ DELETE FROM "select"
69556960 ```
69566961
69576962
@@ -9774,7 +9779,7 @@ Expr(Bytes("Hello")).contains(Bytes("ll"))
97749779
97759780
97769781# # ExprMathOps
9777- Math operations; supported by H2/ Postgres/ MySql, not supported by Sqlite
9782+ Math operations; supported by H2/ Postgres/ MySql/ MsSql , not supported by Sqlite
97789783# ## ExprMathOps.power
97799784
97809785
@@ -10111,7 +10116,7 @@ val value = DataTypes[Sc](
1011110116 myInt = 12345678,
1011210117 myBigInt = 12345678901L,
1011310118 myDouble = 3.14,
10114- myBoolean = true ,
10119+ myBoolean = false ,
1011510120 myLocalDate = LocalDate.parse("2023-12-20"),
1011610121 myLocalTime = LocalTime.parse("10:15:30"),
1011710122 myLocalDateTime = LocalDateTime.parse("2011-12-03T10:15:30"),
@@ -10122,6 +10127,23 @@ val value = DataTypes[Sc](
1012210127 myEnum = MyEnum.bar
1012310128)
1012410129
10130+ val value2 = DataTypes[Sc](
10131+ 67.toByte,
10132+ mySmallInt = 32767.toShort,
10133+ myInt = 12345678,
10134+ myBigInt = 9876543210L,
10135+ myDouble = 2.71,
10136+ myBoolean = true,
10137+ myLocalDate = LocalDate.parse("2020-02-22"),
10138+ myLocalTime = LocalTime.parse("03:05:01"),
10139+ myLocalDateTime = LocalDateTime.parse("2021-06-07T02:01:03"),
10140+ myUtilDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").parse("2021-06-07T02:01:03.000"),
10141+ myInstant = Instant.parse("2021-06-07T02:01:03Z"),
10142+ myVarBinary = new geny.Bytes(Array[Byte](9, 8, 7, 6, 5, 4, 3, 2)),
10143+ myUUID = new java.util.UUID(9876543210L, 1234567890L),
10144+ myEnum = MyEnum.baz
10145+ )
10146+
1012510147db.run(
1012610148 DataTypes.insert.columns(
1012710149 _.myTinyInt := value.myTinyInt,
@@ -10140,8 +10162,26 @@ db.run(
1014010162 _.myEnum := value.myEnum
1014110163 )
1014210164) ==> 1
10165+ db.run(
10166+ DataTypes.insert.columns(
10167+ _.myTinyInt := value2.myTinyInt,
10168+ _.mySmallInt := value2.mySmallInt,
10169+ _.myInt := value2.myInt,
10170+ _.myBigInt := value2.myBigInt,
10171+ _.myDouble := value2.myDouble,
10172+ _.myBoolean := value2.myBoolean,
10173+ _.myLocalDate := value2.myLocalDate,
10174+ _.myLocalTime := value2.myLocalTime,
10175+ _.myLocalDateTime := value2.myLocalDateTime,
10176+ _.myUtilDate := value2.myUtilDate,
10177+ _.myInstant := value2.myInstant,
10178+ _.myVarBinary := value2.myVarBinary,
10179+ _.myUUID := value2.myUUID,
10180+ _.myEnum := value2.myEnum
10181+ )
10182+ ) ==> 1
1014310183
10144- db.run(DataTypes.select) ==> Seq(value)
10184+ db.run(DataTypes.select) ==> Seq(value, value2 )
1014510185` ` `
1014610186
1014710187
@@ -11181,6 +11221,24 @@ val rowSome = OptDataTypes[Sc](
1118111221 myUUID = Some(new java.util.UUID(1234567890L, 9876543210L)),
1118211222 myEnum = Some(MyEnum.bar)
1118311223)
11224+ val rowSome2 = OptDataTypes[Sc](
11225+ myTinyInt = Some(67.toByte),
11226+ mySmallInt = Some(32767.toShort),
11227+ myInt = Some(23456789),
11228+ myBigInt = Some(9876543210L),
11229+ myDouble = Some(2.71),
11230+ myBoolean = Some(false),
11231+ myLocalDate = Some(LocalDate.parse("2020-02-22")),
11232+ myLocalTime = Some(LocalTime.parse("03:05:01")),
11233+ myLocalDateTime = Some(LocalDateTime.parse("2021-06-07T02:01:03")),
11234+ myUtilDate = Some(
11235+ new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").parse("2021-06-07T02:01:03.000")
11236+ ),
11237+ myInstant = Some(Instant.parse("2021-06-07T02:01:03Z")),
11238+ myVarBinary = Some(new geny.Bytes(Array[Byte](9, 8, 7, 6, 5, 4, 3, 2))),
11239+ myUUID = Some(new java.util.UUID(9876543210L, 1234567890L)),
11240+ myEnum = Some(MyEnum.baz)
11241+ )
1118411242
1118511243val rowNone = OptDataTypes[Sc](
1118611244 myTinyInt = None,
@@ -11198,12 +11256,11 @@ val rowNone = OptDataTypes[Sc](
1119811256 myUUID = None,
1119911257 myEnum = None
1120011258)
11201-
1120211259db.run(
11203- OptDataTypes.insert.values(rowSome, rowNone)
11204- ) ==> 2
11260+ OptDataTypes.insert.values(rowSome, rowSome2, rowNone)
11261+ ) ==> 3
1120511262
11206- db.run(OptDataTypes.select) ==> Seq(rowSome, rowNone)
11263+ db.run(OptDataTypes.select) ==> Seq(rowSome, rowSome2, rowNone)
1120711264` ` `
1120811265
1120911266
@@ -12376,3 +12433,80 @@ db.concatWs(" ", "i", "am", "cow", 1337)
1237612433 ```
1237712434
1237812435
12436+
12437+ ## MsSqlDialect
12438+ Operations specific to working with Microsoft SQL Databases
12439+ ### MsSqlDialect.top
12440+
12441+ For ScalaSql' s Microsoft SQL dialect provides, the ` .take(n)` operator translates
12442+ into a SQL ` TOP(n)` clause
12443+
12444+ ` ` ` scala
12445+ Buyer.select.take(0)
12446+ ` ` `
12447+
12448+
12449+ *
12450+ ` ` ` sql
12451+ SELECT TOP(?) buyer0.id AS id, buyer0.name AS name, buyer0.date_of_birth AS date_of_birth
12452+ FROM buyer buyer0
12453+ ` ` `
12454+
12455+
12456+
12457+ *
12458+ ` ` ` scala
12459+ Seq[Buyer[Sc]]()
12460+ ` ` `
12461+
12462+
12463+
12464+ # ## MsSqlDialect.bool vs bit
12465+
12466+ Insert rows with BIT values
12467+
12468+ ` ` ` scala
12469+ db.run(
12470+ BoolTypes.insert.columns(
12471+ _.nullable := value.nullable,
12472+ _.nonNullable := value.nonNullable,
12473+ _.a := value.a,
12474+ _.b := value.b,
12475+ _.comment := value.comment
12476+ )
12477+ ) ==> 1
12478+ db.run(
12479+ BoolTypes.insert.columns(
12480+ _.nullable := value2.nullable,
12481+ _.nonNullable := value2.nonNullable,
12482+ _.a := value2.a,
12483+ _.b := value2.b,
12484+ _.comment := value2.comment
12485+ )
12486+ ) ==> 1
12487+ ` ` `
12488+
12489+
12490+
12491+
12492+
12493+
12494+ # ## MsSqlDialect.uodate BIT
12495+
12496+
12497+
12498+ ` ` ` scala
12499+ BoolTypes
12500+ .update(_.a ` = ` 1)
12501+ .set(_.nonNullable := true)
12502+ ` ` `
12503+
12504+
12505+ *
12506+ ` ` ` sql
12507+ UPDATE bool_types SET non_nullable = ? WHERE (bool_types.a = ?)
12508+ ` ` `
12509+
12510+
12511+
12512+
0 commit comments