You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Formulas specified with either @Formula decorator or via @Property({ formula: ... }) are not used by mikro when explicitly selecting the property
#2705
Describe the bug
Formulas specified with either @Formula decorator or via @Property({ formula: ... }) are not used by mikro when explicitly selecting the property.
Example:
With:
@Entity()
class ConversationEntity {
...
@Formula((alias) => `${alias}.id is not null`)
isReplyPending?: boolean;
}
[query] select`is_reply_pending` from `conversation` as `e0` limit 1 [took 5 ms]
[Nest] 45606 - 02/03/2022, 3:01:01 PM ERROR [ExceptionsHandler] select`is_reply_pending` from `conversation` as `e0` limit 1 - Unknown column 'is_reply_pending'in'field list'
Error: select`is_reply_pending` from `conversation` as `e0` limit 1 - Unknown column 'is_reply_pending'in'field list'
at Packet.asError (/Users/carlos/Dev/leadgogo/test/nestks-mikro-formula/node_modules/.pnpm/mysql2@2.3.2/node_modules/mysql2/lib/packets/packet.js:728:17)
at Query.execute (/Users/carlos/Dev/leadgogo/test/nestks-mikro-formula/node_modules/.pnpm/mysql2@2.3.2/node_modules/mysql2/lib/commands/command.js:29:26)
at Connection.handlePacket (/Users/carlos/Dev/leadgogo/test/nestks-mikro-formula/node_modules/.pnpm/mysql2@2.3.2/node_modules/mysql2/lib/connection.js:456:32)
at PacketParser.onPacket (/Users/carlos/Dev/leadgogo/test/nestks-mikro-formula/node_modules/.pnpm/mysql2@2.3.2/node_modules/mysql2/lib/connection.js:85:12)
at PacketParser.executeStart (/Users/carlos/Dev/leadgogo/test/nestks-mikro-formula/node_modules/.pnpm/mysql2@2.3.2/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket.<anonymous> (/Users/carlos/Dev/leadgogo/test/nestks-mikro-formula/node_modules/.pnpm/mysql2@2.3.2/node_modules/mysql2/lib/connection.js:92:25)
at Socket.emit (node:events:390:28)
at Socket.emit (node:domain:475:12)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
Additional context
Tested with both entity manager and query builder. The result is always the same.
Versions
Dependency
Version
node
16.13.1
typescript
4.5.5
mikro-orm
4.5.10
your-driver
mysql
The text was updated successfully, but these errors were encountered:
Describe the bug
Formulas specified with either
@Formula
decorator or via@Property({ formula: ... })
are not used by mikro when explicitly selecting the property.Example:
With:
This works:
The resulting query is:
This doesn't:
Stack trace
Additional context
Tested with both entity manager and query builder. The result is always the same.
Versions
The text was updated successfully, but these errors were encountered: