question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find any primary keys for Table entity

See original GitHub issue

Hey hey hey! 😃

In case I have a table with a schema like this:

CREATE TABLE `mytable` (
  `id` varchar(14) DEFAULT NULL,
  `my_uuid` int(11) NOT NULL AUTO_INCREMENT,
  `other` varchar(14) DEFAULT NULL,
  `my_id` varchar(14) DEFAULT NULL,
  `contact` varchar(255) DEFAULT NULL,
  `name` varchar(75) DEFAULT NULL,
  UNIQUE KEY `display_id` (`my_uuid`),
  UNIQUE KEY `name` (`name`),
  KEY `mytable_contact` (`contact`),
  KEY `mytable_other` (`other`),
  KEY `mytable_my_id` (`my_id`)
);

Platformatic will fail with this error:

Error: Cannot find any primary keys for AnonymousCard entity:
    at connect (poc-platformatic/node_modules/@platformatic/sql-mapper/mapper.js:120:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async sqlMapper (poc-platformatic/node_modules/@platformatic/sql-mapper/mapper.js:157:18)

Is there a way to skip the constraint that requires a primary key to be defined? 😊

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
rozzillacommented, Dec 18, 2022

Tested it right now, and it works smoothly 🙏🏼

1reaction
mcollinacommented, Dec 16, 2022

An alternative could be that if the primary key is missing, instead of throw, we can log it and skip this table…

That’s what I implemented in https://github.com/platformatic/platformatic/pull/499.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Entity Framework: table without primary key
Some tables do not have primary keys defined so that when I create a new Entity Data Model, I get the following message:...
Read more >
Add or change a table's primary key in Access
Select the field or fields that you want to use as the primary key. To select one field, click the row selector for...
Read more >
Determining Keys for Tables
If a column permits null values, it cannot be part of a primary key. Some entities have ready-made primary keys such as catalog...
Read more >
3 common foreign key mistakes (and how to avoid them)
Foreign key constraints are important to any SQL database, but they can also cause problems if they're not implemented correctly.
Read more >
Entity Model generated has all columns in tables marked ...
For what it's worth, I experience something similar to this when adding a View to my EF model. I know views can't have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found