Skip to content

Commit 7154517

Browse files
committed
fix warnings and deprecations
1 parent 14d6abf commit 7154517

File tree

5 files changed

+29
-28
lines changed

5 files changed

+29
-28
lines changed

source/ddbc/common.d

+2-2
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ class ParameterMetaDataImpl : ParameterMetaData {
430430
this.cols = cols;
431431
}
432432
ref ParameterMetaDataItem col(int column) {
433-
enforceEx!SQLException(column >=1 && column <= cols.length, "Parameter index out of range");
433+
enforce!SQLException(column >=1 && column <= cols.length, "Parameter index out of range");
434434
return cols[column - 1];
435435
}
436436
// Retrieves the fully-qualified name of the Java class whose instances should be passed to the method PreparedStatement.setObject.
@@ -462,7 +462,7 @@ class ResultSetMetaDataImpl : ResultSetMetaData {
462462
this.cols = cols;
463463
}
464464
ref ColumnMetadataItem col(int column) {
465-
enforceEx!SQLException(column >=1 && column <= cols.length, "Column index out of range");
465+
enforce!SQLException(column >=1 && column <= cols.length, "Column index out of range");
466466
return cols[column - 1];
467467
}
468468
//Returns the number of columns in this ResultSet object.

source/ddbc/drivers/mysqlddbc.d

+5-5
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ private:
329329

330330
public:
331331
void checkClosed() {
332-
enforceEx!SQLException(!closed, "Statement is already closed");
332+
enforce!SQLException(!closed, "Statement is already closed");
333333
}
334334

335335
void lock() {
@@ -796,8 +796,8 @@ class MySQLResultSet : ResultSetImpl {
796796

797797
Variant getValue(int columnIndex) {
798798
checkClosed();
799-
enforceEx!SQLException(columnIndex >= 1 && columnIndex <= columnCount, "Column index out of bounds: " ~ to!string(columnIndex));
800-
enforceEx!SQLException(currentRowIndex >= 0 && currentRowIndex < rowCount, "No current row in result set");
799+
enforce!SQLException(columnIndex >= 1 && columnIndex <= columnCount, "Column index out of bounds: " ~ to!string(columnIndex));
800+
enforce!SQLException(currentRowIndex >= 0 && currentRowIndex < rowCount, "No current row in result set");
801801
Row[] rs = results.array;
802802
lastIsNull = rs[currentRowIndex].isNull(columnIndex - 1);
803803
Variant res;
@@ -1138,8 +1138,8 @@ public:
11381138
checkClosed();
11391139
lock();
11401140
scope(exit) unlock();
1141-
enforceEx!SQLException(columnIndex >= 1 && columnIndex <= columnCount, "Column index out of bounds: " ~ to!string(columnIndex));
1142-
enforceEx!SQLException(currentRowIndex >= 0 && currentRowIndex < rowCount, "No current row in result set");
1141+
enforce!SQLException(columnIndex >= 1 && columnIndex <= columnCount, "Column index out of bounds: " ~ to!string(columnIndex));
1142+
enforce!SQLException(currentRowIndex >= 0 && currentRowIndex < rowCount, "No current row in result set");
11431143
return results.array[currentRowIndex].isNull(columnIndex - 1);
11441144
}
11451145

source/ddbc/drivers/odbcddbc.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module ddbc.drivers.odbcddbc;
2323

2424
import std.algorithm;
2525
import std.conv;
26-
import std.datetime;
26+
import std.datetime.date;
2727
import std.exception;
2828
import std.stdio;
2929
import std.string;

source/ddbc/drivers/pgsqlddbc.d

+12-12
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ version(USE_PGSQL) {
432432

433433
public:
434434
void checkClosed() {
435-
enforceEx!SQLException(!closed, "Statement is already closed");
435+
enforce!SQLException(!closed, "Statement is already closed");
436436
}
437437

438438
void lock() {
@@ -589,9 +589,9 @@ version(USE_PGSQL) {
589589
scope(exit) unlock();
590590

591591
PGresult * res = PQexec(conn.getConnection(), std.string.toStringz(query));
592-
enforceEx!SQLException(res !is null, "Failed to execute statement " ~ query);
592+
enforce!SQLException(res !is null, "Failed to execute statement " ~ query);
593593
auto status = PQresultStatus(res);
594-
enforceEx!SQLException(status == PGRES_TUPLES_OK, getError());
594+
enforce!SQLException(status == PGRES_TUPLES_OK, getError());
595595
scope(exit) PQclear(res);
596596

597597
// cmd = new Command(conn.getConnection(), query);
@@ -631,9 +631,9 @@ version(USE_PGSQL) {
631631
lock();
632632
scope(exit) unlock();
633633
PGresult * res = PQexec(conn.getConnection(), std.string.toStringz(query));
634-
enforceEx!SQLException(res !is null, "Failed to execute statement " ~ query);
634+
enforce!SQLException(res !is null, "Failed to execute statement " ~ query);
635635
auto status = PQresultStatus(res);
636-
enforceEx!SQLException(status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK, getError());
636+
enforce!SQLException(status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK, getError());
637637
scope(exit) PQclear(res);
638638

639639
string rowsAffected = copyCString(PQcmdTuples(res));
@@ -741,7 +741,7 @@ version(USE_PGSQL) {
741741
}
742742
void checkParams() {
743743
foreach(i, b; paramIsSet)
744-
enforceEx!SQLException(b, "Parameter " ~ to!string(i) ~ " is not set");
744+
enforce!SQLException(b, "Parameter " ~ to!string(i) ~ " is not set");
745745
}
746746
void setParam(int index, string value) {
747747
checkIndex(index);
@@ -776,7 +776,7 @@ version(USE_PGSQL) {
776776
cast(const int *)lengths.ptr,
777777
cast(const int *)formats.ptr,
778778
0);
779-
enforceEx!SQLException(res !is null, "Error while executing prepared statement " ~ query);
779+
enforce!SQLException(res !is null, "Error while executing prepared statement " ~ query);
780780
metadata = createMetadata(res);
781781
return res;
782782
}
@@ -821,7 +821,7 @@ version(USE_PGSQL) {
821821
PGresult * res = exec();
822822
scope(exit) PQclear(res);
823823
auto status = PQresultStatus(res);
824-
enforceEx!SQLException(status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK, getError(res));
824+
enforce!SQLException(status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK, getError(res));
825825

826826
string rowsAffected = copyCString(PQcmdTuples(res));
827827
//auto lastid = PQoidValue(res);
@@ -998,8 +998,8 @@ version(USE_PGSQL) {
998998

999999
Variant getValue(int columnIndex) {
10001000
checkClosed();
1001-
enforceEx!SQLException(columnIndex >= 1 && columnIndex <= columnCount, "Column index out of bounds: " ~ to!string(columnIndex));
1002-
enforceEx!SQLException(currentRowIndex >= 0 && currentRowIndex < rowCount, "No current row in result set");
1001+
enforce!SQLException(columnIndex >= 1 && columnIndex <= columnCount, "Column index out of bounds: " ~ to!string(columnIndex));
1002+
enforce!SQLException(currentRowIndex >= 0 && currentRowIndex < rowCount, "No current row in result set");
10031003
Variant res = data[currentRowIndex][columnIndex - 1];
10041004
lastIsNull = (res == null);
10051005
return res;
@@ -1327,8 +1327,8 @@ version(USE_PGSQL) {
13271327
checkClosed();
13281328
lock();
13291329
scope(exit) unlock();
1330-
enforceEx!SQLException(columnIndex >= 1 && columnIndex <= columnCount, "Column index out of bounds: " ~ to!string(columnIndex));
1331-
enforceEx!SQLException(currentRowIndex >= 0 && currentRowIndex < rowCount, "No current row in result set");
1330+
enforce!SQLException(columnIndex >= 1 && columnIndex <= columnCount, "Column index out of bounds: " ~ to!string(columnIndex));
1331+
enforce!SQLException(currentRowIndex >= 0 && currentRowIndex < rowCount, "No current row in result set");
13321332
return data[currentRowIndex][columnIndex - 1] == null;
13331333
}
13341334

source/ddbc/drivers/sqliteddbc.d

+9-8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ version(USE_SQLITE) {
3636
//import ddbc.drivers.sqlite;
3737
import ddbc.drivers.utils;
3838
import etc.c.sqlite3;
39+
import std.traits : isSomeString;
3940

4041

4142
version (Windows) {
@@ -294,7 +295,7 @@ version(USE_SQLITE) {
294295

295296
public:
296297
void checkClosed() {
297-
enforceEx!SQLException(!closed, "Statement is already closed");
298+
enforce!SQLException(!closed, "Statement is already closed");
298299
}
299300

300301
void lock() {
@@ -386,7 +387,7 @@ version(USE_SQLITE) {
386387
&stmt, /* OUT: Statement handle */
387388
null /* OUT: Pointer to unused portion of zSql */
388389
);
389-
enforceEx!SQLException(res == SQLITE_OK, "Error #" ~ to!string(res) ~ " while preparing statement " ~ query ~ " : " ~ conn.getError());
390+
enforce!SQLException(res == SQLITE_OK, "Error #" ~ to!string(res) ~ " while preparing statement " ~ query ~ " : " ~ conn.getError());
390391
paramMetadata = createParamMetadata();
391392
paramCount = paramMetadata.getParameterCount();
392393
metadata = createMetadata();
@@ -400,7 +401,7 @@ version(USE_SQLITE) {
400401
// before execution of query
401402
private void allParamsSet() {
402403
for(int i = 0; i < paramCount; i++) {
403-
enforceEx!SQLException(paramIsSet[i], "Parameter " ~ to!string(i + 1) ~ " is not set");
404+
enforce!SQLException(paramIsSet[i], "Parameter " ~ to!string(i + 1) ~ " is not set");
404405
}
405406
if (preparing) {
406407
preparing = false;
@@ -473,7 +474,7 @@ version(USE_SQLITE) {
473474

474475
closeResultSet();
475476
int res = sqlite3_finalize(stmt);
476-
enforceEx!SQLException(res == SQLITE_OK, "Error #" ~ to!string(res) ~ " while closing prepared statement " ~ query ~ " : " ~ conn.getError());
477+
enforce!SQLException(res == SQLITE_OK, "Error #" ~ to!string(res) ~ " while closing prepared statement " ~ query ~ " : " ~ conn.getError());
477478
closed = true;
478479
conn.onStatementClosed(this);
479480
}
@@ -512,7 +513,7 @@ version(USE_SQLITE) {
512513
// row is available
513514
rowsAffected = -1;
514515
} else {
515-
enforceEx!SQLException(false, "Error #" ~ to!string(res) ~ " while trying to execute prepared statement: " ~ " : " ~ conn.getError());
516+
enforce!SQLException(false, "Error #" ~ to!string(res) ~ " while trying to execute prepared statement: " ~ " : " ~ conn.getError());
516517
}
517518
return rowsAffected;
518519
}
@@ -527,7 +528,7 @@ version(USE_SQLITE) {
527528
lock();
528529
scope(exit) unlock();
529530
allParamsSet();
530-
enforceEx!SQLException(metadata.getColumnCount() > 0, "Query doesn't return result set");
531+
enforce!SQLException(metadata.getColumnCount() > 0, "Query doesn't return result set");
531532
resultSet = new SQLITEResultSet(this, stmt, getMetaData());
532533
return resultSet;
533534
}
@@ -680,7 +681,7 @@ version(USE_SQLITE) {
680681

681682
// checks index, updates lastIsNull, returns column type
682683
int checkIndex(int columnIndex) {
683-
enforceEx!SQLException(columnIndex >= 1 && columnIndex <= columnCount, "Column index out of bounds: " ~ to!string(columnIndex));
684+
enforce!SQLException(columnIndex >= 1 && columnIndex <= columnCount, "Column index out of bounds: " ~ to!string(columnIndex));
684685
int res = sqlite3_column_type(rs, columnIndex - 1);
685686
lastIsNull = (res == SQLITE_NULL);
686687
return res;
@@ -790,7 +791,7 @@ version(USE_SQLITE) {
790791
columnCount = sqlite3_data_count(rs);
791792
return true;
792793
} else {
793-
enforceEx!SQLException(false, "Error #" ~ to!string(res) ~ " while reading query result: " ~ copyCString(sqlite3_errmsg(stmt.conn.getConnection())));
794+
enforce!SQLException(false, "Error #" ~ to!string(res) ~ " while reading query result: " ~ copyCString(sqlite3_errmsg(stmt.conn.getConnection())));
794795
return false;
795796
}
796797
}

0 commit comments

Comments
 (0)