Skip to content

Commit

Permalink
Fix empty execute result array for MariaDB version 10.1 (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
predetermined authored Nov 17, 2020
1 parent aa55b90 commit a34cf38
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- mysql:8
- mysql:latest
- mariadb:5.5
- mariadb:10.1
- mariadb:10.2
- mariadb:10.3
- mariadb:10.4
Expand Down
13 changes: 10 additions & 3 deletions src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class Connection {
* and "x.y.z-MariaDB-[build-infos]" for 5.x versions
* eg "5.5.64-MariaDB-1~trusty"
*/
private lessThan57(): Boolean {
private lessThan5_7(): Boolean {
const version = this.serverVersion;
if (!version.includes("MariaDB")) return version < "5.7.0";
const segments = version.split("-");
Expand All @@ -172,6 +172,13 @@ export class Connection {
return false;
}

/** Checks if the MariaDB version is 10.1 */
private isMariaDBAndVersion10_1(): Boolean {
const version = this.serverVersion;
if (!version.includes("MariaDB")) return false;
return version.includes("5.5.5-10.1");
}

/** Close database connection */
close(): void {
if (this.state != ConnectionState.CLOSED) {
Expand Down Expand Up @@ -232,8 +239,8 @@ export class Connection {
}

const rows = [];
if (this.lessThan57()) {
// EOF(less than 5.7)
if (this.lessThan5_7() || this.isMariaDBAndVersion10_1()) {
// EOF(less than 5.7 or mariadb version 10.1)
receive = await this.nextPacket();
if (receive.type !== "EOF") {
throw new ProtocolError();
Expand Down

0 comments on commit a34cf38

Please sign in to comment.