spring-ai icon indicating copy to clipboard operation
spring-ai copied to clipboard

Add SQL Server support to `JdbcSessionRepository`

Open durgadasepalli opened this issue 1 month ago • 4 comments

Expected Behavior

JdbcSessionRepository works with Microsoft SQL Server, and JdbcSessionRepositoryDialect.from() detects it automatically, as it does for PostgreSQL, MySQL, MariaDB and H2.

Current Behavior

JdbcSessionRepositoryDialect.from() throws IllegalStateException for SQL Server, so session memory cannot be used on it. #7186 lists SQL Server among the dialects needed before chat memory is removed in 3.0.

Adding a dialect alone is not enough: JdbcSessionRepository builds two queries with LIMIT (the newest compaction boundary, and the last-N window in findEvents), and SQL Server has no LIMIT.

Context

I'd like to contribute this. Proposed change:

  • SqlServerJdbcSessionRepositoryDialect with a MERGE-based upsert
  • a dialect method for the row-limit clause: LIMIT ? by default, OFFSET 0 ROWS FETCH NEXT ? ROWS ONLY on SQL Server, which Oracle could reuse later
  • schema-sqlserver.sql, detection of "Microsoft SQL Server" in from(), and an integration test using the SQL Server Testcontainer

Happy to adjust the approach based on feedback.

durgadasepalli avatar Oct 29 '26 02:10 durgadasepalli

Hi @durgadasepalli, thanks for opening this.

I'm interested in adding an Oracle dialect, which would need the same OFFSET ... FETCH limit clause you proposed here. Would it be okay if I follow up with Oracle once your PR lands, building on your change?

1o18z avatar Nov 02 '26 04:11 1o18z

Hi @1o18z, sounds good.

I’ll keep the limit clause a dialect method so Oracle can reuse it as is, and I’ll ping you here once the PR is up.

durgadasepalli avatar Nov 02 '26 22:11 durgadasepalli

@1o18z the PR is up: #7301.

JdbcSessionRepositoryDialect.getLimitClause() is the hook for Oracle.

durgadasepalli avatar Nov 02 '26 22:11 durgadasepalli

Thanks @durgadasepalli! I'll start on Oracle once #7301 is merged.

1o18z avatar Nov 03 '26 06:11 1o18z