Skip to content

Commit 74cd5ad

Browse files
committed
use String instead of Symbol
Symbol literal deprecated since Scala 2.13
1 parent 0b981b2 commit 74cd5ad

File tree

8 files changed

+47
-47
lines changed

8 files changed

+47
-47
lines changed

core/src/test/scala/parameterbinderfactory/AccountSpec.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class AccountSpec extends FlatSpec with Matchers with DBSettings with Logging {
3434

3535
it should "insert person with custom binder sync" in {
3636

37-
val result: Int = NamedDB('mysql).autoCommit { implicit s =>
37+
val result: Int = NamedDB("mysql").autoCommit { implicit s =>
3838
withSQL {
3939
insert.into(Person).namedValues(
4040
personColumn.id -> personId,
@@ -45,7 +45,7 @@ class AccountSpec extends FlatSpec with Matchers with DBSettings with Logging {
4545
}
4646

4747
it should "insert account with custom binder async" in {
48-
val resultsFuture: Future[Int] = NamedAsyncDB('mysql).withPool { implicit s =>
48+
val resultsFuture: Future[Int] = NamedAsyncDB("mysql").withPool { implicit s =>
4949
withSQL {
5050
insert.into(Account).namedValues(
5151
accountColumn.id -> accountId,
@@ -58,7 +58,7 @@ class AccountSpec extends FlatSpec with Matchers with DBSettings with Logging {
5858
}
5959

6060
it should "insert account with custom binder with parent set to Some async" in {
61-
val resultsFuture: Future[Int] = NamedAsyncDB('mysql).withPool { implicit s =>
61+
val resultsFuture: Future[Int] = NamedAsyncDB("mysql").withPool { implicit s =>
6262
withSQL {
6363
insert.into(Account).namedValues(
6464
accountColumn.id -> accountId2,
@@ -73,7 +73,7 @@ class AccountSpec extends FlatSpec with Matchers with DBSettings with Logging {
7373

7474
it should "select person joining account with custom binder sync" in {
7575

76-
val result: Option[PersonWithAccounts] = NamedDB('mysql).readOnly { implicit s =>
76+
val result: Option[PersonWithAccounts] = NamedDB("mysql").readOnly { implicit s =>
7777
withSQL {
7878
selectFrom(Person as p).join(Account as acc).on(p.id, acc.personId)
7979
.where.eq(p.id, personId)
@@ -89,7 +89,7 @@ class AccountSpec extends FlatSpec with Matchers with DBSettings with Logging {
8989

9090
it should "select person joining account with custom binder async" in {
9191

92-
val resultFuture: Future[Option[PersonWithAccounts]] = NamedAsyncDB('mysql).withPool { implicit s =>
92+
val resultFuture: Future[Option[PersonWithAccounts]] = NamedAsyncDB("mysql").withPool { implicit s =>
9393
withSQL {
9494
selectFrom(Person as p).join(Account as acc).on(p.id, acc.personId)
9595
.where.eq(p.id, personId)
@@ -105,7 +105,7 @@ class AccountSpec extends FlatSpec with Matchers with DBSettings with Logging {
105105
}
106106

107107
it should "select account joining person with custom binder sync" in {
108-
val result: Option[AccountAndPerson] = NamedDB('mysql).readOnly { implicit s =>
108+
val result: Option[AccountAndPerson] = NamedDB("mysql").readOnly { implicit s =>
109109
withSQL {
110110
selectFrom(Account as acc)
111111
.join(Person as p)
@@ -123,7 +123,7 @@ class AccountSpec extends FlatSpec with Matchers with DBSettings with Logging {
123123
}
124124

125125
it should "select account joining person with custom binder async" in {
126-
val resultsFuture: Future[Option[AccountAndPerson]] = NamedAsyncDB('mysql).withPool { implicit s =>
126+
val resultsFuture: Future[Option[AccountAndPerson]] = NamedAsyncDB("mysql").withPool { implicit s =>
127127
withSQL {
128128
selectFrom(Account as acc)
129129
.join(Person as p)

core/src/test/scala/parameterbinderfactory/PersonSpec.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class PersonSpec extends FlatSpec with Matchers with DBSettings with Logging {
1818

1919
it should "insert person with custom binder sync" in {
2020

21-
val result: Int = NamedDB('mysql).autoCommit { implicit s =>
21+
val result: Int = NamedDB("mysql").autoCommit { implicit s =>
2222
withSQL {
2323
insert.into(Person).namedValues(
2424
column.id -> PersonId(1),
@@ -29,7 +29,7 @@ class PersonSpec extends FlatSpec with Matchers with DBSettings with Logging {
2929
}
3030

3131
it should "insert person with custom binder async" in {
32-
val resultsFuture: Future[Int] = NamedAsyncDB('mysql).withPool { implicit s =>
32+
val resultsFuture: Future[Int] = NamedAsyncDB("mysql").withPool { implicit s =>
3333
withSQL {
3434
insert.into(Person).namedValues(
3535
column.id -> PersonId(2),
@@ -44,7 +44,7 @@ class PersonSpec extends FlatSpec with Matchers with DBSettings with Logging {
4444
val id = PersonId(12)
4545
val name = "testperson"
4646

47-
val result: Option[Person] = NamedDB('mysql).readOnly { implicit s =>
47+
val result: Option[Person] = NamedDB("mysql").readOnly { implicit s =>
4848
withSQL {
4949
selectFrom(Person as p).where.eq(p.id, id)
5050
}.map(Person(p)).single.apply()
@@ -56,7 +56,7 @@ class PersonSpec extends FlatSpec with Matchers with DBSettings with Logging {
5656
val id = PersonId(12)
5757
val name = "testperson"
5858

59-
val resultsFuture: Future[Option[Person]] = NamedAsyncDB('mysql).withPool { implicit s =>
59+
val resultsFuture: Future[Option[Person]] = NamedAsyncDB("mysql").withPool { implicit s =>
6060
withSQL {
6161
selectFrom(Person as p).where.eq(p.id, id)
6262
}.map(Person(p)).single.future()
@@ -67,7 +67,7 @@ class PersonSpec extends FlatSpec with Matchers with DBSettings with Logging {
6767

6868
it should "update person with custom binder sync" in {
6969

70-
val result: Int = NamedDB('mysql).autoCommit { implicit s =>
70+
val result: Int = NamedDB("mysql").autoCommit { implicit s =>
7171
withSQL {
7272
update(Person).set(
7373
column.id -> PersonId(3),
@@ -79,7 +79,7 @@ class PersonSpec extends FlatSpec with Matchers with DBSettings with Logging {
7979

8080
it should "update person with custom binder async" in {
8181

82-
val resultsFuture: Future[Int] = NamedAsyncDB('mysql).withPool { implicit s =>
82+
val resultsFuture: Future[Int] = NamedAsyncDB("mysql").withPool { implicit s =>
8383
withSQL {
8484
update(Person).set(
8585
column.id -> PersonId(4),
@@ -93,7 +93,7 @@ class PersonSpec extends FlatSpec with Matchers with DBSettings with Logging {
9393

9494
it should "delete person with custom binder sync" in {
9595

96-
val result: Int = NamedDB('mysql).autoCommit { implicit s =>
96+
val result: Int = NamedDB("mysql").autoCommit { implicit s =>
9797
withSQL {
9898
deleteFrom(Person).where.eq(column.id, PersonId(3))
9999
}.update.apply()
@@ -103,7 +103,7 @@ class PersonSpec extends FlatSpec with Matchers with DBSettings with Logging {
103103

104104
it should "delete person with custom binder async" in {
105105

106-
val resultsFuture: Future[Int] = NamedAsyncDB('mysql).withPool { implicit s =>
106+
val resultsFuture: Future[Int] = NamedAsyncDB("mysql").withPool { implicit s =>
107107
withSQL {
108108
deleteFrom(Person).where.eq(column.id, PersonId(4))
109109
}.update.future()

core/src/test/scala/sample/MySQLSampleSpec.scala

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
1515
val al = AsyncLover.syntax("al")
1616

1717
it should "select a single value" in {
18-
val id = NamedDB('mysql).autoCommit { implicit s =>
18+
val id = NamedDB("mysql").autoCommit { implicit s =>
1919
withSQL {
2020
insert.into(AsyncLover).namedValues(
2121
column.name -> "Eric",
@@ -24,15 +24,15 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
2424
column.createdAt -> createdTime)
2525
}.updateAndReturnGeneratedKey.apply()
2626
}
27-
val resultFuture: Future[Option[AsyncLover]] = NamedAsyncDB('mysql).withPool { implicit s =>
27+
val resultFuture: Future[Option[AsyncLover]] = NamedAsyncDB("mysql").withPool { implicit s =>
2828
withSQL { select.from(AsyncLover as al).where.eq(al.id, id) }.map(AsyncLover(al)).single.future()
2929
}
3030
val result = Await.result(resultFuture, 5.seconds)
3131
result.isDefined should be(true)
3232
}
3333

3434
it should "select values as a Iterable" in {
35-
val resultsFuture: Future[Iterable[AsyncLover]] = NamedAsyncDB('mysql).withPool { implicit s =>
35+
val resultsFuture: Future[Iterable[AsyncLover]] = NamedAsyncDB("mysql").withPool { implicit s =>
3636
withSQL {
3737
select.from(AsyncLover as al)
3838
.where.isNotNull(al.birthday) // mysql-async 0.2.4 cannot parse nullable date value.
@@ -44,7 +44,7 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
4444
}
4545

4646
it should "select values as a List" in {
47-
val resultsFuture: Future[List[AsyncLover]] = NamedAsyncDB('mysql).withPool { implicit s =>
47+
val resultsFuture: Future[List[AsyncLover]] = NamedAsyncDB("mysql").withPool { implicit s =>
4848
withSQL {
4949
select.from(AsyncLover as al)
5050
.where.isNotNull(al.birthday) // mysql-async 0.2.4 cannot parse nullable date value.
@@ -56,7 +56,7 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
5656
}
5757

5858
it should "read values with convenience methods" in {
59-
val generatedIdFuture: Future[Long] = NamedAsyncDB('mysql).withPool { implicit s =>
59+
val generatedIdFuture: Future[Long] = NamedAsyncDB("mysql").withPool { implicit s =>
6060
withSQL {
6161
insert.into(AsyncLover).namedValues(
6262
column.name -> "Eric",
@@ -67,7 +67,7 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
6767
}
6868
// in AsyncLover#apply we are using get with typebinders, specialized getters should work
6969
val generatedId = Await.result(generatedIdFuture, 5.seconds)
70-
val created = NamedDB('mysql).readOnly { implicit s =>
70+
val created = NamedDB("mysql").readOnly { implicit s =>
7171
withSQL { select.from(AsyncLover as al).where.eq(al.id, generatedId) }.map((rs: WrappedResultSet) => {
7272
AsyncLover(
7373
id = rs.get[Long](al.resultName.id),
@@ -87,7 +87,7 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
8787
}
8888

8989
it should "return generated key" in {
90-
val generatedIdFuture: Future[Long] = NamedAsyncDB('mysql).withPool { implicit s =>
90+
val generatedIdFuture: Future[Long] = NamedAsyncDB("mysql").withPool { implicit s =>
9191
withSQL {
9292
insert.into(AsyncLover).namedValues(
9393
column.name -> "Eric",
@@ -99,7 +99,7 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
9999
}
100100
// the generated key should be found
101101
val generatedId = Await.result(generatedIdFuture, 5.seconds)
102-
val created = NamedDB('mysql).readOnly { implicit s =>
102+
val created = NamedDB("mysql").readOnly { implicit s =>
103103
withSQL { select.from(AsyncLover as al).where.eq(al.id, generatedId) }.map(AsyncLover(al)).single.apply()
104104
}.get
105105
created.id should equal(generatedId)
@@ -111,7 +111,7 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
111111

112112
it should "update" in {
113113
// updating queries should be successful
114-
NamedDB('mysql) autoCommit { implicit s =>
114+
NamedDB("mysql") autoCommit { implicit s =>
115115
withSQL { delete.from(AsyncLover).where.eq(column.id, 1004) }.update.apply()
116116
withSQL {
117117
insert.into(AsyncLover).namedValues(
@@ -122,21 +122,21 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
122122
column.createdAt -> createdTime)
123123
}.update.apply()
124124
}
125-
val deletion: Future[Int] = NamedAsyncDB('mysql).withPool { implicit s =>
125+
val deletion: Future[Int] = NamedAsyncDB("mysql").withPool { implicit s =>
126126
withSQL { delete.from(AsyncLover).where.eq(column.id, 1004) }.update.future()
127127
}
128128
Await.result(deletion, 5.seconds)
129129

130130
// should be committed
131-
val deleted = NamedDB('mysql).readOnly { implicit s =>
131+
val deleted = NamedDB("mysql").readOnly { implicit s =>
132132
withSQL { select.from(AsyncLover as al).where.eq(al.id, 1004) }.map(AsyncLover(al)).single.apply()
133133
}
134134
deleted.isDefined should be(false)
135135
}
136136

137137
it should "execute" in {
138138
// execution should be successful
139-
val id = NamedDB('mysql).autoCommit { implicit s =>
139+
val id = NamedDB("mysql").autoCommit { implicit s =>
140140
withSQL {
141141
insert.into(AsyncLover).namedValues(
142142
column.name -> "Chris",
@@ -145,13 +145,13 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
145145
column.createdAt -> createdTime)
146146
}.updateAndReturnGeneratedKey.apply()
147147
}
148-
val deletion: Future[Boolean] = NamedAsyncDB('mysql).withPool { implicit s =>
148+
val deletion: Future[Boolean] = NamedAsyncDB("mysql").withPool { implicit s =>
149149
withSQL { delete.from(AsyncLover).where.eq(column.id, id) }.execute.future()
150150
}
151151
Await.result(deletion, 5.seconds)
152152

153153
// should be committed
154-
val deleted = NamedDB('mysql).readOnly { implicit s =>
154+
val deleted = NamedDB("mysql").readOnly { implicit s =>
155155
withSQL { select.from(AsyncLover as al).where.eq(al.id, id) }.map(AsyncLover(al)).single.apply()
156156
}
157157
deleted.isDefined should be(false)
@@ -160,7 +160,7 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
160160
it should "update in a local transaction" in {
161161
(1 to 10).foreach { _ =>
162162

163-
val generatedIdFuture: Future[Long] = NamedAsyncDB('mysql).localTx { implicit tx =>
163+
val generatedIdFuture: Future[Long] = NamedAsyncDB("mysql").localTx { implicit tx =>
164164
withSQL(insert.into(AsyncLover).namedValues(
165165
column.name -> "Patric",
166166
column.rating -> 2,
@@ -169,7 +169,7 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
169169
).updateAndReturnGeneratedKey.future
170170
}
171171
val generatedId = Await.result(generatedIdFuture, 5.seconds)
172-
val created = NamedDB('mysql).readOnly { implicit s =>
172+
val created = NamedDB("mysql").readOnly { implicit s =>
173173
withSQL { select.from(AsyncLover as al).where.eq(al.id, generatedId) }.map(AsyncLover(al)).single.apply()
174174
}.get
175175
created.id should equal(generatedId)
@@ -183,10 +183,10 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
183183
it should "rollback in a local transaction" in {
184184
(1 to 10).foreach { _ =>
185185

186-
NamedDB('mysql).autoCommit { implicit s =>
186+
NamedDB("mysql").autoCommit { implicit s =>
187187
withSQL { delete.from(AsyncLover).where.eq(column.id, 1003) }.update.apply()
188188
}
189-
val failureFuture: Future[Unit] = NamedAsyncDB('mysql).localTx { implicit tx =>
189+
val failureFuture: Future[Unit] = NamedAsyncDB("mysql").localTx { implicit tx =>
190190
import FutureImplicits._
191191
for {
192192
_ <- insert.into(AsyncLover).namedValues(
@@ -208,7 +208,7 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
208208
failureFuture.value.get.isFailure should be(true)
209209

210210
// should be rolled back
211-
val notCreated = NamedDB('mysql).readOnly { implicit s =>
211+
val notCreated = NamedDB("mysql").readOnly { implicit s =>
212212
withSQL { select.from(AsyncLover as al).where.eq(al.id, 1003) }.map(AsyncLover(al)).single.apply()
213213
}
214214
notCreated.isDefined should be(false)
@@ -218,7 +218,7 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
218218
it should "provide transaction by AsyncTx.withSQLBuilders" in {
219219
(1 to 10).foreach { _ =>
220220

221-
val deletionAndCreation: Future[Seq[AsyncQueryResult]] = NamedAsyncDB('mysql).withPool { implicit s =>
221+
val deletionAndCreation: Future[Seq[AsyncQueryResult]] = NamedAsyncDB("mysql").withPool { implicit s =>
222222
AsyncTx.withSQLBuilders(
223223
delete.from(AsyncLover).where.eq(column.id, 997),
224224
insert.into(AsyncLover).namedValues(
@@ -233,7 +233,7 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
233233
deletionAndCreation.value.get.get.size should be(2)
234234

235235
// should be found
236-
val created = NamedDB('mysql).readOnly { implicit s =>
236+
val created = NamedDB("mysql").readOnly { implicit s =>
237237
withSQL { select.from(AsyncLover as al).where.eq(al.id, 997) }.map(AsyncLover(al)).single.apply()
238238
}.get
239239
created.id should equal(997)
@@ -247,10 +247,10 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
247247
it should "provide transactional deletion by AsyncTx.withSQLBuilders" in {
248248
(1 to 10).foreach { _ =>
249249

250-
NamedDB('mysql).autoCommit { implicit s =>
250+
NamedDB("mysql").autoCommit { implicit s =>
251251
withSQL { delete.from(AsyncLover).where.eq(column.id, 998) }.update.apply()
252252
}
253-
val creationAndDeletion: Future[Seq[AsyncQueryResult]] = NamedAsyncDB('mysql).withPool { implicit s =>
253+
val creationAndDeletion: Future[Seq[AsyncQueryResult]] = NamedAsyncDB("mysql").withPool { implicit s =>
254254
AsyncTx.withSQLBuilders(
255255
insert.into(AsyncLover).namedValues(
256256
column.id -> 998,
@@ -265,7 +265,7 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
265265
creationAndDeletion.value.get.get.size should be(2)
266266

267267
// should be committed
268-
val deleted = NamedDB('mysql).readOnly { implicit s =>
268+
val deleted = NamedDB("mysql").readOnly { implicit s =>
269269
withSQL { select.from(AsyncLover as al).where.eq(al.id, 998) }.map(AsyncLover(al)).single.apply()
270270
}
271271
deleted.isDefined should be(false)
@@ -275,7 +275,7 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
275275
it should "rollback in a transaction when using AsyncTx.withSQLs" in {
276276
(1 to 10).foreach { _ =>
277277

278-
val failure: Future[Seq[AsyncQueryResult]] = NamedAsyncDB('mysql).withPool { implicit s =>
278+
val failure: Future[Seq[AsyncQueryResult]] = NamedAsyncDB("mysql").withPool { implicit s =>
279279
AsyncTx.withSQLs(
280280
insert.into(AsyncLover).namedValues(
281281
column.id -> 999,
@@ -294,7 +294,7 @@ class MySQLSampleSpec extends FlatSpec with Matchers with DBSettings with Loggin
294294
}
295295
failure.value.get.isSuccess should be(false)
296296

297-
val notFound = NamedDB('mysql).readOnly { implicit s =>
297+
val notFound = NamedDB("mysql").readOnly { implicit s =>
298298
withSQL { select.from(AsyncLover as al).where.eq(al.id, 999) }.map(AsyncLover(al)).single.apply()
299299
}
300300
notFound.isDefined should be(false)

core/src/test/scala/unit/AccountDBInitializer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ create table account (
1818
values (13, 12, 'test account details', null)""")
1919

2020
def initMySQL(): Unit = {
21-
NamedDB('mysql) autoCommit { implicit s =>
21+
NamedDB("mysql") autoCommit { implicit s =>
2222
try sql"drop table account".execute.apply()
2323
catch { case e: Exception => }
2424

core/src/test/scala/unit/DBSettings.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ trait DBSettings extends ForAllTestContainer { self: Suite =>
2222
PgListDBInitializer.initPostgreSQL()
2323

2424
// MySQL
25-
ConnectionPool.add(Symbol("mysql"), url = mysql.jdbcUrl, user = mysql.username, password = mysql.password)
26-
AsyncConnectionPool.add(Symbol("mysql"), url = mysql.jdbcUrl, user = mysql.username, password = mysql.password)
25+
ConnectionPool.add("mysql", url = mysql.jdbcUrl, user = mysql.username, password = mysql.password)
26+
AsyncConnectionPool.add("mysql", url = mysql.jdbcUrl, user = mysql.username, password = mysql.password)
2727

2828
SampleDBInitializer.initMySQL()
2929
PgListDBInitializer.initMySQL()

core/src/test/scala/unit/PersonDBInitializer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ create table person (
1616
values (12, 'testperson')""")
1717

1818
def initMySQL(): Unit = {
19-
NamedDB('mysql) autoCommit { implicit s =>
19+
NamedDB("mysql") autoCommit { implicit s =>
2020
try sql"drop table person".execute.apply()
2121
catch { case e: Exception => }
2222

core/src/test/scala/unit/PgListDBInitializer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ insert into programmer_skill values (2, 2);
8888
}
8989

9090
def initMySQL(): Unit = {
91-
NamedDB('mysql) autoCommit { implicit s =>
91+
NamedDB("mysql") autoCommit { implicit s =>
9292

9393
try sql"drop table programmer_skill".execute.apply()
9494
catch { case e: Exception => log.debug(e.getMessage, e) }

0 commit comments

Comments
 (0)