Skip to content

Commit

Permalink
refs #2495 fixed a bug in the STRING-TOO-LONG exception
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnich committed Nov 23, 2017
1 parent 2762d89 commit 2c201fe
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
2 changes: 2 additions & 0 deletions doxygen/lang/900_release_notes.dox.tmpl
Expand Up @@ -18,6 +18,8 @@
- the debugger should report ambiguous partial matches as an error (<a href="https://github.com/qorelanguage/qore/issues/2292">issue 2292</a>)
- <a href="../../modules/MailMessage/html/index.html">MailMessage</a> module fixes:
- fixed \c Message::addBody() with no body present (issue <a href="https://github.com/qorelanguage/qore/issues/2360">issue 2360</a>)
- <a href="../../modules/Mapper/html/index.html">Mapper</a> module fixes:
- fixed a bug in the \c STRING-TOO-LONG exception (<a href="https://github.com/qorelanguage/qore/issues/2495">issue 2405</a>)
- <a href="../../modules/Qdx/html/index.html">Qdx</a> module fixes:
- fixed a bug in documentation post-processing for @ref hashdecl "hashdecl" declarations (<a href="https://github.com/qorelanguage/qore/issues/2298">issue 2298</a>)
- <a href="../../modules/QUnit/html/index.html">QUnit</a> fixes:
Expand Down
31 changes: 23 additions & 8 deletions examples/test/qlib/Mapper/mapper.qtest
Expand Up @@ -35,11 +35,12 @@ public class MapperTest inherits QUnit::Test {
"sr0.sr1.^attributes^.type": ("name": "Type", "code": *string sub (*string v, hash rec) { return v ? v.lwr() : NOTHING;}, "default": "unknown"),
"sr0.sr1.key1": ("constant": "key1"),
"sr0.store_name": "StoreInfo.StoreName",
"runtimetest" : ("runtime" : "runtimetest"),
"indextest1" : ("index" : 0),
"indextest2" : ("index" : 1),
"indextest3" : ("index" : "a"),
"empty_string" : "EmptyString",
"runtimetest": ("runtime" : "runtimetest"),
"indextest1": ("index" : 0),
"indextest2": ("index" : 1),
"indextest3": ("index" : "a"),
"empty_string": "EmptyString",
"length_test": ("maxlen": 5, "default": ""),
);

const DataMap2 = (
Expand All @@ -58,7 +59,9 @@ public class MapperTest inherits QUnit::Test {
"ProductName": "Widget 1",
"Quantity": 1,
),
)), (
),
"length_test": NOTHING,
), (
"^attributes^": ("Id": 2),
"name": "Steve Austin",
"Type": "Retail",
Expand Down Expand Up @@ -103,7 +106,8 @@ public class MapperTest inherits QUnit::Test {
);

const MapInput3 = (
"count" : (11, "10", NOTHING));
"count": (11, "10", NOTHING),
);

const MapOutput = ((
"id": 1,
Expand All @@ -130,6 +134,7 @@ public class MapperTest inherits QUnit::Test {
"indextest2" : 1,
"indextest3" : "a0",
"empty_string" : "",
"length_test": "",
), (
"id": 2,
"name": "Steve Austin",
Expand All @@ -155,6 +160,7 @@ public class MapperTest inherits QUnit::Test {
"indextest2" : 2,
"indextest3" : "a1",
"empty_string" : "",
"length_test": "",
),
);

Expand Down Expand Up @@ -207,6 +213,7 @@ public class MapperTest inherits QUnit::Test {
addTestCase("Test mapAll() with hash arg", \testMapperMapAllHash());
addTestCase("Test mapFieldType", \testMapperMapFieldType());
addTestCase("Dot test", \dotTest());
addTestCase("field length test", \testFieldLength());
set_return_value(main());
}

Expand Down Expand Up @@ -273,7 +280,7 @@ public class MapperTest inherits QUnit::Test {
}

testEmptyString() {
Mapper m(DataMap, m_opts + ( "empty_strings_to_nothing" : True ) );
Mapper m(DataMap, m_opts + ("empty_strings_to_nothing": True));
list l = m.mapAll(MapInput);
list o = MapOutput;
# simulate "old empty string to NOTHING conversion"
Expand All @@ -282,6 +289,14 @@ public class MapperTest inherits QUnit::Test {
assertEq(l, o);
}

testFieldLength() {
Mapper m(DataMap, m_opts);
list input = MapInput;
input[0].length_test = "longer string";
# test issue #2495
assertThrows("STRING-TOO-LONG", "length_test", \m.mapAll(), (input,));
}

testMapperMapAllHash() {
Mapper m(DataMap, m_opts);
list l = m.mapAll(MapInput2);
Expand Down
3 changes: 2 additions & 1 deletion qlib/Mapper.qm
Expand Up @@ -221,6 +221,7 @@ m.mapData(input1); # output record hash date_begin = start_date = time

@subsection mapperv1_4 Mapper v1.4
- added support for complex types
- fixed a bug in the \c STRING-TOO-LONG exception (<a href="https://github.com/qorelanguage/qore/issues/2495">issue 2405</a>)

@subsection mapperv1_3_1 Mapper v1.3.1
- fixed bugs handling mapper fields with no input records in list mode as passed from the \c TableMapper module (<a href="https://github.com/qorelanguage/qore/issues/1736">issue 1736</a>)
Expand Down Expand Up @@ -1117,7 +1118,7 @@ Mapper mapv(DataMap);
v = truncateField(key, v, 0, 0, m.maxlen);
}
else
fieldLengthError(key, $1, 0, 0, m.maxlen, rec);
fieldLengthError(key, v, 0, 0, m.maxlen, rec);
}
}
}
Expand Down

0 comments on commit 2c201fe

Please sign in to comment.