Skip to content

feat(adapter): Support supportsArrays option - #84

Open
Rebne wants to merge 3 commits into
octet-stream:mainfrom
Rebne:feat/supports-arrays-option
Open

feat(adapter): Support supportsArrays option#84
Rebne wants to merge 3 commits into
octet-stream:mainfrom
Rebne:feat/supports-arrays-option

Conversation

@Rebne

@Rebne Rebne commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Details

Adds support for Better Auth's supportsArrays adapter capability flag in the MikroORM adapter.

Why

This adapter currently does not expose Better Auth’s supportsArrays capability, so Better Auth falls back to its default array serialization behavior.

For databases with native array support, that can lead to array fields being encoded twice. This PR adds support for passing supportsArrays through the MikroORM adapter so those setups can opt into the correct behavior.

Related issue

I ran into this while using Better Auth’s OAuth provider plugin, where several array-backed OAuth fields were being double-encoded when the adapter did not advertise native array support.

Changes

  • Add supportsArrays to MikroOrmAdapterConfig
  • Pass supportsArrays through to createAdapterFactory
  • Add adapter-level coverage for constructing the adapter with supportsArrays: true

Checklist

  • I have self-reviewed my changes before asking for a review from maintainers
  • I have added changesets
  • I have brought tests
  • I have updated the documentation

@changeset-bot

changeset-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2ecd0f7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
better-auth-mikro-orm Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment thread tests/node/adapter.test.ts Outdated
Comment on lines +25 to +41
test("accepts supportsArrays config", async () => {
const adapter = mikroOrmAdapter(orm, {
debugLogs: {
isRunningAdapterTests: true
},
supportsArrays: true
})({})

const user = randomUsers.createOne()
const actual = await adapter.create<UserInput, DatabaseUser>({
model: "user",
data: user
})

expect(actual).toMatchObject(user)
})

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what's being tested here. From the description I'd say you should check that adapter has this option after it's being created. I think you can do it via:

expect(adapter.options?.adapterConfig.supportsArrays).toBe(true)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixup: 2d3d0e1

Comment thread tests/node/adapter.test.ts Outdated
Comment on lines +363 to +387
const users = await orm.em.find(entities.User, {
id: {$in: [user1.id, user2.id, user3.id]}
})
const users: InstanceType<typeof entities.User>[] = await orm.em.find(
entities.User,
{
id: {$in: [user1.id, user2.id, user3.id]}
}
)

expect(users.map(({emailVerified}) => emailVerified)).toMatchObject([
expect(users.map(user => user.emailVerified)).toMatchObject([

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks unnecessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixup: a181a73

@codecov

codecov Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.59%. Comparing base (fd75f09) to head (2ecd0f7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #84      +/-   ##
==========================================
+ Coverage   92.51%   92.59%   +0.07%     
==========================================
  Files           3        3              
  Lines         187      189       +2     
  Branches       47       49       +2     
==========================================
+ Hits          173      175       +2     
  Misses         14       14              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Rebne
Rebne force-pushed the feat/supports-arrays-option branch 3 times, most recently from a181a73 to 50e550d Compare August 20, 2026 08:27
@Rebne
Rebne requested a review from octet-stream August 20, 2026 08:27
@Rebne
Rebne force-pushed the feat/supports-arrays-option branch from 50e550d to 2ecd0f7 Compare August 26, 2026 06:42
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.

2 participants