Skip to content

[codex] Use wpdb insert identity field#28

Closed
alexstandiford wants to merge 1 commit into
mainfrom
codex/wpdb-insert-identity
Closed

[codex] Use wpdb insert identity field#28
alexstandiford wants to merge 1 commit into
mainfrom
codex/wpdb-insert-identity

Conversation

@alexstandiford
Copy link
Copy Markdown
Contributor

Summary

  • Resolve auto-increment insert identities from the table's declared identity field instead of hardcoding id.
  • Treat a missing wpdb->insert_id as a datastore failure after a successful insert call.
  • Add unit coverage for provided identities, auto-increment identities, and unresolved identities.

Why

WordPress' insert path calls $wpdb->insert() and then uses $wpdb->insert_id from the same database connection. This keeps identity resolution in the write path instead of requiring callers to infer or re-query the record.

Validation

  • vendor/bin/phpunit --filter CanQueryWordPressDatabaseTest --testdox
  • vendor/bin/phpunit --testdox

@alexstandiford
Copy link
Copy Markdown
Contributor Author

Closing this because it only validates the wpdb insert ID in the WordPress adapter. It does not address the actual create-path issue, which is that PHPNomad db immediately rereads after insert instead of following WordPress' insert-then-use-identity pattern.

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

Successfully merging this pull request may close these issues.

1 participant