HaxeFoundation / record-macros

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

Haxe 4 updates #33

Closed filt3rek closed 5 years ago

filt3rek commented 5 years ago

Hej,

There are some issues using Haxe 4 preview : -https://github.com/HaxeFoundation/record-macros/blob/master/src/sys/db/RecordMacros.hx#L470 : C:\HaxeToolkit\haxe\lib\record-macros/git/src/sys/db/RecordMacros.hx:470: characters 13-20 : Warning : private structure fields are deprecated -https://github.com/HaxeFoundation/record-macros/blob/master/src/sys/db/RecordMacros.hx#L1108 : C:\HaxeToolkit\haxe\std/haxe/macro/Context.hx:558: characters 3-8 : Uncaught exception This method is no longer supported. See https://github.com/HaxeFoundation/haxe/issues/5746

For the first one it is easy to fix but what about onMacroContextReused ? I don't know how to fix that. I don't know how can I help someone to fix all that please ? (There are some issues for hx3compat too, it would be great to update all that also in order to make it work with Haxe 4)

filt3rek commented 5 years ago

if (haxe_ver < 4)

blabla

end

for https://github.com/HaxeFoundation/record-macros/blob/master/src/sys/db/RecordMacros.hx#L1108 and https://github.com/HaxeFoundation/record-macros/blob/master/src/sys/db/RecordMacros.hx#L1137 That's ok But how to do with https://github.com/HaxeFoundation/record-macros/blob/master/src/sys/db/RecordMacros.hx#L470 in a clean way without "cast" please ?

jonasmalacofilho commented 5 years ago

That is not a cast. The issue is that in Haxe 4 you can no longer use that private modifier.

A way to fix that is to use proper access control:

    @:access(sys.db.Manager)
    function quoteField( f : String ) {
        var keywords = Manager.KEYWORDS;
        return keywords.exists(f.toLowerCase()) ? "`"+f+"`" : f;
    }

Take a look at jonasmalacofilho/record-macros@more-haxe-4-fixes. I've been meaning to improve one thing before pushing the fixes here.

filt3rek commented 5 years ago

Thanks Jonas for your answer, I know it's not a cast, but I use that to make it work :

var m : { KEYWORDS : haxe.ds.StringMap<Bool> } = cast Manager;
return m.KEYWORDS.exists(f.toLowerCase()) ? "`"+f+"`" : f;

Your solution here is better ! But how to do another way, as it was previously done using the type when you cannot use visibility in anonymous structures ? If someone know...

bablukid commented 5 years ago

Wow, you rock @jonasmalacofilho ... I was just loosing time on this yesterday !