Skip to content

feat(pdo): statement-level get/set-attribute via polymorphic dispatch#26

Merged
Chemaclass merged 2 commits into
mainfrom
feat/12-statement-attributes
Jun 3, 2026
Merged

feat(pdo): statement-level get/set-attribute via polymorphic dispatch#26
Chemaclass merged 2 commits into
mainfrom
feat/12-statement-attributes

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

Wraps PDOStatement::getAttribute / setAttribute. Rather than introduce new names that collide with the connection-level accessors in the single phel.pdo namespace, get-attribute / set-attribute now dispatch on the handle (per the option suggested in #12):

(pdo/get-attribute conn \PDO/ATTR_ERRMODE)   ;; connection (unchanged)
(pdo/get-attribute stmt \PDO/ATTR_CURSOR)     ;; statement

A private attr-target helper resolves :pdo vs :stmt from the struct type (statement?), keeping both accessors a one-liner. (declare statement?) added before the (load "pdo/statement") so the predicate resolves cross-file.

Note on the test driver

Statement attributes are driver-specific. SQLite (the test driver) doesn't support them: getAttribute raises IM001 and setAttribute is a no-op returning false. The tests therefore prove routing - that the statement branch reaches the PDOStatement (observable via the \PDOException) while the connection branch keeps returning values. The wrapper is fully functional for drivers that support statement attributes (e.g. MySQL).

  • Removed both methods from the "Not implemented yet" block in src/pdo/statement.phel.
  • Tests: set-attribute-dispatches-to-statement, get-attribute-dispatches-to-statement (connection + statement branches). Existing attribute-roundtrip still green.
  • README + CHANGELOG (### Changed) updated.

Polish pass: extracted attr-target to remove the get/set duplication.

composer test green (41 assertions).

Closes #12

@Chemaclass Chemaclass added the enhancement New feature or request label Jun 3, 2026
@Chemaclass Chemaclass self-assigned this Jun 3, 2026
@Chemaclass Chemaclass merged commit eaa4775 into main Jun 3, 2026
1 check passed
@Chemaclass Chemaclass deleted the feat/12-statement-attributes branch June 3, 2026 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement statement attribute access (get-attribute / set-attribute)

1 participant