Skip to content

Commit 897e4ea

Browse files
committed
The big doc update. Also cleaned up a bunch of imports and little things
I saw while documenting.
1 parent 6adb77b commit 897e4ea

27 files changed

+682
-197
lines changed

SAFE_MIGRATION.md

Lines changed: 103 additions & 21 deletions
Large diffs are not rendered by default.

build-docs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/sh
2-
rdmd --build-only -c -Isource -Dddocs_tmp -X -Xfdocs/docs.json -version=MySQLDocs --force source/mysql/package.d
3-
rm -rf docs_tmp
2+
# Need taggedalgebraic
3+
rm -rf ta
4+
git clone https://github.com/s-ludwig/taggedalgebraic.git ta
5+
rdmd --build-only -c -Isource -Ita/source -Dddocs_tmp -X -Xfdocs/docs.json -version=MySQLDocs --force source/mysql/package.d
6+
rm -rf docs_tmp ta
47
rm source/mysql/package.o
58

69
dub --version

ddoc/macros.ddoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ Macros:
66
DOLLAR = $
77
COLON = :
88
EM = $(B $(I $0) )
9-
9+
1010
TYPE_MAPPINGS = See the $(LINK2 $(DDOX_ROOT_DIR)/mysql.html, MySQL/D Type Mappings tables)
11-
11+
SAFE_MIGRATION = See the $(LINK2 https://github.com/mysql-d/mysql-native/blob/master/SAFE_MIGRATION.md, Safe Migration) document for more details.
12+
1213
STD_DATETIME_DATE = $(D_INLINECODE $(LINK2 https://dlang.org/phobos/std_datetime_date.html#$0, $0))
1314
STD_EXCEPTION = $(D_INLINECODE $(LINK2 https://dlang.org/phobos/std_exception.html#$0, $0))
1415
STD_FILE = $(D_INLINECODE $(LINK2 https://dlang.org/phobos/std_file.html#$0, $0))

source/mysql/commands.d

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/++
2-
This module imports `mysql.unsafe.commands`, which provides the Variant-based
3-
interface to mysql. In the future, this will switch to importing the
2+
This module publicly imports `mysql.unsafe.commands`, which provides the
3+
Variant-based interface to mysql. In the future, this will switch to importing the
44
`mysql.safe.commands`, which provides the @safe interface to mysql. Please see
55
those two modules for documentation on the functions provided. It is highly
66
recommended to import `mysql.safe.commands` and not the unsafe commands, as
77
that is the future for mysql-native.
88
99
In the far future, the unsafe version will be deprecated and removed, and the
1010
safe version moved to this location.
11+
12+
$(SAFE_MIGRATION)
1113
+/
1214
module mysql.commands;
1315
public import mysql.unsafe.commands;

source/mysql/connection.d

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/++
2+
This module publicly imports `mysql.unsafe.connection`, which provides
3+
backwards compatible functions for connecting to a MySQL/MariaDB server.
4+
5+
It is recommended instead to import `mysql.safe.connection`, which provides
6+
@safe-only mechanisms to connect to a database.
7+
8+
Note that the common pieces of the connection are documented and currently
9+
reside in `mysql.impl.connection`. The safe and unsafe portions of the API
10+
reside in `mysql.unsafe.connection` and `mysql.safe.connection` respectively.
11+
Please see these modules for information on using a MySQL `Connection` object.
12+
13+
In the future, this will migrate to importing `mysql.safe.connection`. In the
14+
far future, the unsafe version will be deprecated and removed, and the safe
15+
version moved to this location.
16+
17+
$(SAFE_MIGRATION)
18+
+/
119
module mysql.connection;
220

321
public import mysql.unsafe.connection;

source/mysql/escape.d

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ properly escaped all using the buffer that formattedWrite provides.
4040
4141
Params:
4242
Input = (Template Param) Type of the input
43+
44+
Note:
45+
The delegate is expected to be @safe as of version 3.1.0.
4346
+/
4447
struct MysqlEscape ( Input )
4548
{
@@ -65,7 +68,7 @@ MysqlEscape!(T) mysqlEscape ( T ) ( T input )
6568

6669
@("mysqlEscape")
6770
debug(MYSQLN_TESTS)
68-
unittest
71+
@safe unittest
6972
{
7073
import std.array : appender;
7174

source/mysql/internal/connection.d renamed to source/mysql/impl/connection.d

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
/// Connect to a MySQL/MariaDB server.
2-
module mysql.internal.connection;
1+
/++
2+
Connect to a MySQL/MariaDB server.
3+
4+
WARNING:
5+
This module is used to consolidate the common implementation of the safe and
6+
unafe API. DO NOT directly import this module, please import one of
7+
`mysql.connection`, `mysql.safe.connection`, or `mysql.unsafe.connection`. This
8+
module will be removed in a future version without deprecation.
9+
10+
$(SAFE_MIGRATION)
11+
+/
12+
module mysql.impl.connection;
313

414
import std.algorithm;
515
import std.conv;
@@ -14,8 +24,8 @@ import mysql.protocol.comms;
1424
import mysql.protocol.constants;
1525
import mysql.protocol.packets;
1626
import mysql.protocol.sockets;
17-
import mysql.internal.result;
18-
import mysql.internal.prepared;
27+
import mysql.impl.result;
28+
import mysql.impl.prepared;
1929
import mysql.types;
2030

2131
@safe:

source/mysql/internal/pool.d renamed to source/mysql/impl/pool.d

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@ If you don't want to, refer to `mysql.connection.Connection`.
88
This provides various benefits over creating a new connection manually,
99
such as automatically reusing old connections, and automatic cleanup (no need to close
1010
the connection when done).
11+
12+
WARNING:
13+
This module is used to consolidate the common implementation of the safe and
14+
unafe API. DO NOT directly import this module, please import one of
15+
`mysql.pool`, `mysql.safe.pool`, or `mysql.unsafe.pool`. This module will be
16+
removed in a future version without deprecation.
17+
18+
$(SAFE_MIGRATION)
1119
+/
12-
module mysql.internal.pool;
20+
module mysql.impl.pool;
1321

1422
import std.conv;
1523
import std.typecons;
16-
import mysql.connection;
17-
import mysql.prepared;
24+
import mysql.impl.connection;
25+
import mysql.impl.prepared;
1826
import mysql.protocol.constants;
1927
debug(MYSQLN_TESTS)
2028
{
@@ -86,8 +94,14 @@ version(IncludeMySQLPool)
8694
8795
If, for any reason, this class doesn't suit your needs, it's easy to just
8896
use vibe.d's $(LINK2 http://vibed.org/api/vibe.core.connectionpool/ConnectionPool, ConnectionPool)
89-
directly. Simply provide it with a delegate that creates a new `mysql.connection.Connection`
90-
and does any other custom processing if needed.
97+
directly. Simply provide it with a delegate that creates a new
98+
`mysql.impl.connection.Connection` and does any other custom processing if
99+
needed.
100+
101+
You should not use this template directly, but rather import
102+
`mysql.safe.pool` or `mysql.unsafe.pool` or `mysql.pool`, which will alias
103+
MySQLPool to the correct instantiation. The boolean parameter here
104+
specifies whether the pool is operating in safe mode or unsafe mode.
91105
+/
92106
class MySQLPoolImpl(bool isSafe)
93107
{
@@ -198,7 +212,7 @@ version(IncludeMySQLPool)
198212
return lockConnectionImpl();
199213
}
200214

201-
// the implementation we want to imply attributes
215+
// the implementation we want to infer attributes
202216
private final lockConnectionImpl()
203217
{
204218
auto conn = m_pool.lockConnection();
@@ -376,7 +390,7 @@ version(IncludeMySQLPool)
376390

377391
/// Is the given statement set to be automatically registered on all
378392
/// connections obtained from this connection pool?
379-
bool isAutoRegistered(Prepared prepared) @safe
393+
bool isAutoRegistered(SafePrepared prepared) @safe
380394
{
381395
return isAutoRegistered(prepared.sql);
382396
}
@@ -393,7 +407,7 @@ version(IncludeMySQLPool)
393407

394408
/// Is the given statement set to be automatically released on all
395409
/// connections obtained from this connection pool?
396-
bool isAutoReleased(Prepared prepared) @safe
410+
bool isAutoReleased(SafePrepared prepared) @safe
397411
{
398412
return isAutoReleased(prepared.sql);
399413
}
@@ -415,7 +429,7 @@ version(IncludeMySQLPool)
415429
416430
Equivalent to `!isAutoRegistered && !isAutoReleased`.
417431
+/
418-
bool isAutoCleared(Prepared prepared) @safe
432+
bool isAutoCleared(SafePrepared prepared) @safe
419433
{
420434
return isAutoCleared(prepared.sql);
421435
}
@@ -490,9 +504,15 @@ version(IncludeMySQLPool)
490504
static void doit(bool isSafe)()
491505
{
492506
static if(isSafe)
507+
{
493508
import mysql.safe.commands;
509+
import mysql.safe.connection;
510+
}
494511
else
512+
{
495513
import mysql.unsafe.commands;
514+
import mysql.unsafe.connection;
515+
}
496516
alias MySQLPool = MySQLPoolImpl!isSafe;
497517
auto pool = new MySQLPool(testConnectionStr);
498518

0 commit comments

Comments
 (0)