Skip to content

Commit 087abf5

Browse files
committed
Fixed bugs
1 parent c0c4d3f commit 087abf5

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

ydb/public/lib/ydb_cli/common/csv_parser.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class TCsvToYdbConverter {
186186
break;
187187
}
188188
case TTypeParser::ETypeKind::Pg: {
189-
if (token == NullValue) {
189+
if (NullValue && token == NullValue) {
190190
Builder.Pg(TPgValue(TPgValue::VK_NULL, {}, Parser.GetPg()));
191191
} else {
192192
Builder.Pg(TPgValue(TPgValue::VK_TEXT, TString(token), Parser.GetPg()));
@@ -250,6 +250,9 @@ class TCsvToYdbConverter {
250250
}
251251

252252
void EnsureNull(TStringBuf token) const {
253+
if (!NullValue) {
254+
throw TMisuseException() << "Expected null value instead of \"" << token << "\", but null value is not set.";
255+
}
253256
if (token != NullValue) {
254257
throw TMisuseException() << "Expected null value: \"" << NullValue << "\", recieved: \"" << token << "\".";
255258
}

ydb/public/lib/ydb_cli/common/progress_bar.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,30 @@ void TProgressBar::AddProgress(size_t value) {
2424
Render();
2525
}
2626

27+
TProgressBar::~TProgressBar() {
28+
if (!Finished) {
29+
Cout << Endl;
30+
}
31+
}
32+
2733
void TProgressBar::Render()
2834
{
2935
std::optional<size_t> barLenOpt = GetTerminalWidth();
3036
if (!barLenOpt)
3137
return;
3238

3339
size_t barLen = *barLenOpt;
34-
TString output = ToString(CurProgress * 100 / Capacity);
40+
TString output = "\r";
41+
output += ToString(CurProgress * 100 / Capacity);
3542
output += "% |";
3643
TString outputEnd = "| [";
3744
outputEnd += ToString(CurProgress);
3845
outputEnd += "/";
3946
outputEnd += ToString(Capacity);
4047
outputEnd += "]";
4148

42-
if (barLen > output.Size()) {
43-
barLen -= output.Size();
49+
if (barLen > output.Size() - 1) {
50+
barLen -= output.Size() - 1;
4451
} else {
4552
barLen = 1;
4653
}
@@ -55,10 +62,10 @@ void TProgressBar::Render()
5562
output += TString("") * filledBarLen;
5663
output += TString("") * (barLen - filledBarLen);
5764
output += outputEnd;
58-
output += "\r";
5965
Cout << output;
6066
if (CurProgress == Capacity) {
6167
Cout << "\n";
68+
Finished = true;
6269
}
6370
Cout.Flush();
6471
}

ydb/public/lib/ydb_cli/common/progress_bar.h

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class TProgressBar {
99
public:
1010
explicit TProgressBar(size_t capacity);
1111

12+
~TProgressBar();
13+
1214
void SetProcess(size_t progress);
1315

1416
void AddProgress(size_t value);
@@ -18,6 +20,7 @@ class TProgressBar {
1820

1921
size_t Capacity = 0;
2022
size_t CurProgress = 0;
23+
bool Finished = false;
2124
};
2225

2326
} // namespace NConsoleClient

0 commit comments

Comments
 (0)