Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Id<T> fails to cast to Int in haxe 4.2.2 #144

Open
serjek opened this issue Aug 26, 2021 · 2 comments
Open

Id<T> fails to cast to Int in haxe 4.2.2 #144

serjek opened this issue Aug 26, 2021 · 2 comments

Comments

@serjek
Copy link

serjek commented Aug 26, 2021

Example below compiles just fine (apart from deprecation warnings) in haxe 4.1.5 but fails to compile in 4.2.2 with following error:

src/MainMinimal.hx:38: lines 38-43 : error: tink.sql.Id<Room> should be Int
src/MainMinimal.hx:38: lines 38-43 : ... have: tink.Promise<Array<{ id: tink.sql.Id<...> }>>
src/MainMinimal.hx:38: lines 38-43 : ... want: tink.Promise<Array<{ id: Int }>>

Minimal example:

package;
import tink.sql.drivers.MySql;
import tink.sql.Types;
using tink.CoreApi;

typedef User = {
	@:primary @:autoIncrement @:optional final id:Id<User>;
}

typedef Room = {
	@:primary @:autoIncrement @:optional final id:Id<Room>;
	final user:Id<User>;
}

typedef MyData = {
	final user:Int;
	final id:Int;
}

@:tables(User,Room)
class Db extends tink.sql.Database {}

class MainMinimal {

	public static function main() new MainMinimal();

	var db:Db;
	public function new() {
		var driver:MySql = new MySql({
			user: 'root',
			password: '',
			host: '127.0.0.1',
			port: 3306
		});
		db = new Db('test', driver);

		test().eager();
	}

	public function test():Promise<Array<MyData>>
		return db.Room.select({
				id: Room.id,
				user: Room.user
			})
			.where(Room.id > 10)
			.all();
}
-cp src
-main MainMinimal
-dce full

-lib hxnodejs
-lib tink_sql

-js minimal.js
@kevinresol
Copy link
Member

Can you try adding from Int to Id?

@serjek
Copy link
Author

serjek commented Aug 27, 2021

It didn't help, as welll as adding @:transitive to Id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants