node-casbin/sequelize-adapter

Remove or ignore the 'id' column

wy10cheng opened this issue · 11 comments

Hello,

Can I remove or ignore the 'id' column of created casbin_rule table?
If so, where shall I edit? Since I don't see the 'id' field in your model.
Thanks.

I am also facing the same issue, could you please help @17bit

@wy10cheng @rafaellech why don't just ignore the id field?

@wy10cheng @rafaellech why don't just ignore the id field?

since our team is using 2 adapters to write the table in different project. once the adapter with 'id' is built, the other project with JDBC adapter could not find the right table to match and raise error, and vice versa

@wy10cheng @rafaellech why don't just ignore the id field?

i had also found the code is without the part creating the column 'id', so also curious where does this primary key field come from

17bit commented

@wy10cheng @rafaellech why don't just ignore the id field?

since our team is using 2 adapters to write the table in different project. once the adapter with 'id' is built, the other project with JDBC adapter could not find the right table to match and raise error, and vice versa

Could you send the error message? I guess it's Sequelize's problem.

@wy10cheng @rafaellech why don't just ignore the id field?

since our team is using 2 adapters to write the table in different project. once the adapter with 'id' is built, the other project with JDBC adapter could not find the right table to match and raise error, and vice versa

Could you send the error message? I guess it's Sequelize's problem.

Server is running on 5000
Executing (default): SELECT 1+1 AS result
Executing (default): CREATE TABLE IF NOT EXISTS `casbin_rule` (`id` INTEGER NOT NULL auto_increment , `ptype` VARCHAR(255), `v0` VARCHAR(255), `v1` VARCHAR(255), `v2` VARCHAR(255), `v3` VARCHAR(255), `v4` VARCHAR(255), `v5` VARCHAR(255), PRIMARY KEY (`id`)) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM `casbin_rule` FROM `dev`
Executing (default): SELECT `id`, `ptype`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5` FROM `casbin_rule` AS `CasbinRule`;
(node:3016) UnhandledPromiseRejectionWarning: SequelizeDatabaseError: Unknown column 'id' in 'field list'
    at Query.formatError (/Users/michaelcheng/Documents/proj/casbin/casbin-role-backend/node_modules/sequelize/lib/dialects/mysql/query.js:244:16)
    at Query.handler [as onResult] (/Users/michaelcheng/Documents/proj/casbin/casbin-role-backend/node_modules/sequelize/lib/dialects/mysql/query.js:51:23)
    at Query.execute (/Users/michaelcheng/Documents/proj/casbin/casbin-role-backend/node_modules/mysql2/lib/commands/command.js:30:14)
    at Connection.handlePacket (/Users/michaelcheng/Documents/proj/casbin/casbin-role-backend/node_modules/mysql2/lib/connection.js:417:32)
    at PacketParser.onPacket (/Users/michaelcheng/Documents/proj/casbin/casbin-role-backend/node_modules/mysql2/lib/connection.js:75:12)
    at PacketParser.executeStart (/Users/michaelcheng/Documents/proj/casbin/casbin-role-backend/node_modules/mysql2/lib/packet_parser.js:75:16)
    at Socket.<anonymous> (/Users/michaelcheng/Documents/proj/casbin/casbin-role-backend/node_modules/mysql2/lib/connection.js:82:25)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:3016) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3016) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
17bit commented

@wy10cheng @rafaellech why don't just ignore the id field?

since our team is using 2 adapters to write the table in different project. once the adapter with 'id' is built, the other project with JDBC adapter could not find the right table to match and raise error, and vice versa

This is a bug because we do not define a primary key in casbinRule.ts.

@hsluoyz

@hsluoyz can you please help? thanks a lot

@wy10cheng actually our ultimate goal is to add the id column for all adapters.

So if you mean that the Node.js's sequelize-adapter creates the id column but the Java's JDBC adapter doesn't support or recognize it or the whole table, I think we should fix it at the JDBC adapter's side. Can you create a GitHub issue at the JDBC adapter's repo?