HaxeFoundation / record-macros

Macro-based ORM (object-relational mapping)
MIT License
49 stars 24 forks source link

Unit tests fail with Haxe 4.0.0, hxcpp 4.0.38: Missing key foo #43

Closed grepsuzette closed 5 years ago

grepsuzette commented 5 years ago

Had this problem in my project, therefore I ran the unit tests for record-macros.

With hexunit 0.30.0. Haxe 3.4.7 with hxcpp 3.4.188 unit tests pass on both neko and hxcpp. Haxe 4.0.0 with hxcpp 4.0.52 unit tests pass on neko and fail on hxcpp as follow:

hex/unittest/notifier/ConsoleNotifier.hx:47: <<< Start MySQLTest tests run >>>
hex/unittest/notifier/ConsoleNotifier.hx:76:    Test class 'MySQLTest'
hex/unittest/notifier/ConsoleNotifier.hx:102:           * [testDateQuery] .
hex/unittest/notifier/ConsoleNotifier.hx:104:                   hex.error.Exception | Missing key theId
hex/unittest/notifier/ConsoleNotifier.hx:105:                   Missing key theId:
hex/unittest/notifier/ConsoleNotifier.hx:102:           * [testIssue34] Test that cache management doesn't break @:skip fields
hex/unittest/notifier/ConsoleNotifier.hx:104:                   hex.error.Exception | Missing key theid
hex/unittest/notifier/ConsoleNotifier.hx:105:                   Missing key theid:
hex/unittest/notifier/ConsoleNotifier.hx:102:           * [testNull] .
hex/unittest/notifier/ConsoleNotifier.hx:104:                   hex.error.Exception | Missing key theId
hex/unittest/notifier/ConsoleNotifier.hx:105:                   Missing key theId:
hex/unittest/notifier/ConsoleNotifier.hx:102:           * [testIssue3828] .
hex/unittest/notifier/ConsoleNotifier.hx:104:                   hex.error.Exception | Missing key id
hex/unittest/notifier/ConsoleNotifier.hx:105:                   Missing key id:
hex/unittest/notifier/ConsoleNotifier.hx:102:           * [testEnum] .
hex/unittest/notifier/ConsoleNotifier.hx:104:                   hex.error.Exception | Missing key theId
hex/unittest/notifier/ConsoleNotifier.hx:105:                   Missing key theId:
hex/unittest/notifier/ConsoleNotifier.hx:102:           * [testStringIdRel] .
hex/unittest/notifier/ConsoleNotifier.hx:104:                   hex.error.Exception | Missing key name
hex/unittest/notifier/ConsoleNotifier.hx:105:                   Missing key name:
hex/unittest/notifier/ConsoleNotifier.hx:102:           * [testUpdate] .
hex/unittest/notifier/ConsoleNotifier.hx:104:                   hex.error.Exception | Missing key theId
hex/unittest/notifier/ConsoleNotifier.hx:105:                   Missing key theId:
hex/unittest/notifier/ConsoleNotifier.hx:102:           * [testData] .
hex/unittest/notifier/ConsoleNotifier.hx:104:                   hex.error.Exception | Missing key theId
hex/unittest/notifier/ConsoleNotifier.hx:105:                   Missing key theId:
hex/unittest/notifier/ConsoleNotifier.hx:102:           * [testSpodTypes] .
hex/unittest/notifier/ConsoleNotifier.hx:104:                   hex.error.Exception | Missing key theId
hex/unittest/notifier/ConsoleNotifier.hx:105:                   Missing key theId:
hex/unittest/notifier/ConsoleNotifier.hx:93:            * [testIssue6041]  25.93212890625ms
hex/unittest/notifier/ConsoleNotifier.hx:93:            * [testIssue19] Ensure that field types using full paths can be matched 34.487060546875ms
hex/unittest/notifier/ConsoleNotifier.hx:93:            * [testIssue6] Check that relations are not affected by the analyzer 0.112060546875ms
hex/unittest/notifier/ConsoleNotifier.hx:54: <<< End tests run >>>
hex/unittest/notifier/ConsoleNotifier.hx:55: Assertions passed: 8

hex/unittest/notifier/ConsoleNotifier.hx:59: Assertions failed: 9

This is the same exact bug I have in my app as well.

grepsuzette commented 5 years ago

haxe 3.4.7, hxcpp 3.4.188, hexunit 0.35.0: pass for both neko and hxcpp haxe 4.0.0 (just released), hxcpp 4.0.38, hexunit 0.35.0, tink_macro 0.16.1 : fail on hxcpp with an error "Missing key xx", always pass on neko. haxe 4.0.0-rc3, hxcpp 4.0.38, hexunit 0.35.0, tink_macro 0.16.1 : fail on hxcpp (same), pass on neko haxe 4.0.0-rc1, hxcpp 4.0.38, hexunit 0.35.0, tink_macro 0.16.1. fail on hxcpp (same), pass on neko haxe 4.0.0-rc1, hxcpp 4.0.38, hexunit 0.35.0, tink_macro 0.17.7. fail on hxcpp (same), pass on neko

haxe 4.0.0-rc1, hxcpp 4.0.4, hexunit 0.35.0, tink_macro 0.16.1. built failed with:

Error: In file included from ./src/sys/db/_Sqlite/SqliteResultSet.cpp:8:
include/sys/db/ResultSet.h: In static member function ‘static bool sys::db::ResultSet_obj::hasNext(Dynamic)’:
include/sys/db/ResultSet.h:23:30: error: ‘interface_cast’ is not a member of ‘hx’
grepsuzette commented 5 years ago

I suggest first we confirm the bug on whatever combination of dependencies I used before (no point retesting all of them). Is the bug reproduceable on another machine with the same test suite?

jonasmalacofilho commented 5 years ago

Reproduced (haxe 4.0.0, hxcpp 4.0.52) and reduced to:

class Test {
    static function main() {
        var dburl = ~/([^:]+):\/\/([^:]+):([^@]*?)@([^:]+)(:[0-9]+)?\/(.*?)$/;
        if (!dburl.match(Sys.args()[0]))
            throw "Missing cnx params: mysql://user:password@host[:port]/dbname";
        var port = dburl.matched(5);
        var params = {
            user: dburl.matched(2),
            pass: dburl.matched(3),
            host: dburl.matched(4),
            port: port == null ? 3306 : Std.parseInt(port.substr(1)),
            database: dburl.matched(6),
        };
        var cnx = sys.db.Mysql.connect(params);

        trace(cnx.request('SELECT 3.14 pi, 42 life').next());
    }
}
$ haxe --main Test --neko test.n && neko test.n mysql://[...]
Test.hx:16: { life => 42, pi => 3.14 }

$ haxe --main Test --cpp cpp --debug && cpp/Test-debug mysql://[...]
Test.hx:16: { null => 42 }
grepsuzette commented 5 years ago

That's some serious PR you issued there! Congrats on finding it so quickly :)

grepsuzette commented 5 years ago

As said elsewhere, I applied your patch and it solves the ""Missing key xx"" problem.