Skip to content

Commit f57a462

Browse files
authored
Add support for temporal types (#21)
1 parent 01ae99b commit f57a462

File tree

13 files changed

+8604
-172
lines changed

13 files changed

+8604
-172
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,31 @@ on: [push]
55
jobs:
66
build_and_test_ubuntu:
77
strategy:
8-
matrix:
8+
matrix:
99
platform: [ubuntu-20.04]
10+
mg_version:
11+
- 2.0.0
1012
runs-on: ${{ matrix.platform }}
1113
steps:
12-
- name: Install dependencies (Ubuntu 20.04)
13-
if: matrix.platform == 'ubuntu-20.04'
14-
run: |
15-
sudo apt install -y git cmake make gcc g++ libssl-dev # mgconsole deps
16-
sudo apt install -y libpython3.8 python3-pip # memgraph deps
17-
mkdir ~/memgraph
18-
curl -L https://memgraph.com/download/memgraph/v1.4.0/ubuntu-20.04/memgraph_1.4.0-community-1_amd64.deb > ~/memgraph/memgraph_1.4.0-community-1_amd64.deb
19-
sudo systemctl mask memgraph
20-
sudo dpkg -i ~/memgraph/memgraph_1.4.0-community-1_amd64.deb
21-
22-
- uses: actions/checkout@v1
23-
- name: Install and test mgconsole
24-
run: |
25-
mkdir build
26-
cd build
27-
cmake ..
28-
make
29-
sudo make install
30-
ctest
14+
- name: Install dependencies (Ubuntu 20.04)
15+
if: matrix.platform == 'ubuntu-20.04'
16+
run: |
17+
sudo apt install -y git cmake make gcc g++ libssl-dev # mgconsole deps
18+
sudo apt install -y libpython3.8 python3-pip # memgraph deps
19+
mkdir ~/memgraph
20+
curl -L https://download.memgraph.com/memgraph/v${{ matrix.mg_version }}/ubuntu-20.04/memgraph_${{ matrix.mg_version }}-1_amd64.deb > ~/memgraph/memgraph_${{ matrix.mg_version }}-1_amd64.deb
21+
sudo systemctl mask memgraph
22+
sudo dpkg -i ~/memgraph/memgraph_${{ matrix.mg_version }}-1_amd64.deb
23+
24+
- uses: actions/checkout@v1
25+
- name: Install and test mgconsole
26+
run: |
27+
mkdir build
28+
cd build
29+
cmake ..
30+
make
31+
sudo make install
32+
ctest
3133
3234
build_windows:
3335
runs-on: windows-latest
@@ -68,6 +70,10 @@ jobs:
6870
uses: actions/checkout@v2
6971
# NOTE: CI can't execute end2end tests because there is no way to run
7072
# Memgraph on CI MacOS machines.
73+
- name: Install openssl
74+
run: |
75+
brew update
76+
brew install openssl
7177
- name: Build mgconsole
7278
run: |
7379
mkdir build
@@ -79,4 +85,3 @@ jobs:
7985
with:
8086
name: "mgconsole MacOS build"
8187
path: build/src/mgconsole
82-

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# mgconsole - console client for Memgraph database
2-
# Copyright (C) 2016-2020 Memgraph Ltd. [https://memgraph.com]
2+
# Copyright (C) 2016-2021 Memgraph Ltd. [https://memgraph.com]
33
#
44
# This program is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ add_dependencies(${GFLAGS_LIBRARY} gflags-proj)
8484
ExternalProject_Add(mgclient-proj
8585
PREFIX mgclient
8686
GIT_REPOSITORY https://github.com/memgraph/mgclient.git
87-
GIT_TAG v1.2.1
87+
GIT_TAG v1.3.0
8888
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>"
8989
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
9090
${MACOSX_OPENSSL_ROOTDIR_FLAG}

src/main.cpp

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// mgconsole - console client for Memgraph database
2-
// Copyright (C) 2016-2020 Memgraph Ltd. [https://memgraph.com]
2+
// Copyright (C) 2016-2021 Memgraph Ltd. [https://memgraph.com]
33
//
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU General Public License as published by
@@ -37,9 +37,9 @@
3737
#include <mgclient.h>
3838
#include <replxx.h>
3939

40-
#include "version.hpp"
41-
#include "utils/utils.hpp"
4240
#include "utils/constants.hpp"
41+
#include "utils/utils.hpp"
42+
#include "version.hpp"
4343

4444
using namespace std::string_literals;
4545

@@ -95,10 +95,12 @@ int main(int argc, char **argv) {
9595

9696
gflags::ParseCommandLineFlags(&argc, &argv, true);
9797

98-
format::CsvOptions csv_opts{FLAGS_csv_delimiter, FLAGS_csv_escapechar, FLAGS_csv_doublequote};
98+
format::CsvOptions csv_opts{FLAGS_csv_delimiter, FLAGS_csv_escapechar,
99+
FLAGS_csv_doublequote};
99100
format::OutputOptions output_opts{FLAGS_output_format, FLAGS_fit_to_screen};
100101

101-
if (output_opts.output_format == constants::kCsvFormat && !csv_opts.ValidateDoubleQuote()) {
102+
if (output_opts.output_format == constants::kCsvFormat &&
103+
!csv_opts.ValidateDoubleQuote()) {
102104
console::EchoFailure(
103105
"Unsupported combination of 'csv-doublequote' and 'csv-escapechar'\n"
104106
"flags",
@@ -131,16 +133,16 @@ int main(int argc, char **argv) {
131133
password = *password_optional;
132134
} else {
133135
console::EchoFailure("Password not submitted",
134-
"Requested password for username " + FLAGS_username);
136+
"Requested password for username " + FLAGS_username);
135137
cleanup_resources();
136138
return 1;
137139
}
138140
console::SetStdinEcho(true);
139141
}
140142

141143
fs::path history_dir = FLAGS_history;
142-
if (FLAGS_history ==
143-
(constants::kDefaultHistoryBaseDir + "/" + constants::kDefaultHistoryMemgraphDir)) {
144+
if (FLAGS_history == (constants::kDefaultHistoryBaseDir + "/" +
145+
constants::kDefaultHistoryMemgraphDir)) {
144146
// Fetch home dir for user.
145147
history_dir =
146148
utils::GetUserHomeDir() / constants::kDefaultHistoryMemgraphDir;
@@ -230,8 +232,9 @@ int main(int argc, char **argv) {
230232
mg_memory::MgSessionParamsPtr params =
231233
mg_memory::MakeCustomUnique<mg_session_params>(mg_session_params_make());
232234
if (!params) {
233-
console::EchoFailure("Connection failure",
234-
"out of memory, failed to allocate `mg_session_params` struct");
235+
console::EchoFailure(
236+
"Connection failure",
237+
"out of memory, failed to allocate `mg_session_params` struct");
235238
}
236239
mg_session_params_set_host(params.get(), FLAGS_host.c_str());
237240
mg_session_params_set_port(params.get(), FLAGS_port);
@@ -243,21 +246,23 @@ int main(int argc, char **argv) {
243246
mg_session_params_set_sslmode(
244247
params.get(), FLAGS_use_ssl ? MG_SSLMODE_REQUIRE : MG_SSLMODE_DISABLE);
245248

246-
mg_memory::MgSessionPtr session = mg_memory::MakeCustomUnique<mg_session>(nullptr);
249+
mg_memory::MgSessionPtr session =
250+
mg_memory::MakeCustomUnique<mg_session>(nullptr);
247251
{
248252
mg_session *session_tmp;
249253
int status = mg_connect(params.get(), &session_tmp);
250254
session = mg_memory::MakeCustomUnique<mg_session>(session_tmp);
251255
if (status != 0) {
252-
console::EchoFailure("Connection failure", mg_session_error(session.get()));
256+
console::EchoFailure("Connection failure",
257+
mg_session_error(session.get()));
253258
cleanup_resources();
254259
return 1;
255260
}
256261
}
257262

258263
console::EchoInfo("mgconsole "s + gflags::VersionString());
259264
console::EchoInfo("Connected to 'memgraph://" + FLAGS_host + ":" +
260-
std::to_string(FLAGS_port) + "'");
265+
std::to_string(FLAGS_port) + "'");
261266
console::EchoInfo("Type :help for shell usage");
262267
console::EchoInfo("Quit the shell by typing Ctrl-D(eof) or :quit");
263268
int num_retries = 3;
@@ -267,10 +272,12 @@ int main(int argc, char **argv) {
267272
console::EchoInfo("Bye");
268273
break;
269274
}
270-
if (query->empty()) continue;
275+
if (query->empty())
276+
continue;
271277
try {
272278
auto ret = query::ExecuteQuery(session.get(), *query);
273-
if (ret.records.size() > 0) Output(ret.header, ret.records, output_opts, csv_opts);
279+
if (ret.records.size() > 0)
280+
Output(ret.header, ret.records, output_opts, csv_opts);
274281
if (console::is_a_tty(STDIN_FILENO)) {
275282
std::string summary;
276283
if (ret.records.size() == 0) {
@@ -307,7 +314,8 @@ int main(int argc, char **argv) {
307314
int status = mg_connect(params.get(), &session_tmp);
308315
session = mg_memory::MakeCustomUnique<mg_session>(session_tmp);
309316
if (status != 0) {
310-
console::EchoFailure("Connection failure", mg_session_error(session.get()));
317+
console::EchoFailure("Connection failure",
318+
mg_session_error(session.get()));
311319
session.reset(nullptr);
312320
} else {
313321
is_connected = true;
@@ -318,11 +326,11 @@ int main(int argc, char **argv) {
318326
if (is_connected) {
319327
num_retries = 3;
320328
console::EchoInfo("Connected to 'memgraph://" + FLAGS_host + ":" +
321-
std::to_string(FLAGS_port) + "'");
329+
std::to_string(FLAGS_port) + "'");
322330
} else {
323-
console::EchoFailure("Couldn't connect to", "'memgraph://" + FLAGS_host + ":" +
324-
std::to_string(FLAGS_port) +
325-
"'");
331+
console::EchoFailure("Couldn't connect to",
332+
"'memgraph://" + FLAGS_host + ":" +
333+
std::to_string(FLAGS_port) + "'");
326334
cleanup_resources();
327335
return 1;
328336
}

0 commit comments

Comments
 (0)