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.

SQL Server: Support explicit table schema prefix in queries

See original GitHub issue

Hi.

We have an issue when using Ktorm with SQL Server. The queries do not work with a db user which has no default schema, since the schema defined in the connection (e.g. via spring data source) is ignored / not supported by the SQL server driver.

It would be good to be able to enforce a schema prefix in the queries / pass a schema in the entity definition.

E.g.

object DimDate : Table<Nothing>("DimDate", "MySchema") { ... }

=> 

SELECT * FROM MySchema.DimDate

It seems this is not possible right now. Is there a suggested work around?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
vincentlauvlwjcommented, Sep 19, 2020

Supported in Ktorm 3.1.0

0reactions
vincentlauvlwjcommented, Jun 18, 2020

@hangingman Yes, will be a core feature.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bad Habits to Kick : Avoiding the schema prefix - SQLBlog.org
Without an explicit schema, SQL Server will first look under the schema associated with your login. This can cause problems, obviously, ...
Read more >
Why you should always use schema name in queries
The reason is simple: SQL Server does cache the query plan for ad-hoc queries, but if the schema name isn't present in the...
Read more >
How to pass schema prefix to queries that don't contain it
Set the default schema for the user to the schema that your queries need to use. ALTER USER [UserName] WITH DEFAULT_SCHEMA=[SchemaName].
Read more >
The dbo. prefix in database object names, can I ignore it?
If you have all table names explicitly qualified as dbo.x then you cannot change to a different schema without search and replace through...
Read more >
Add namespaces to queries using WITH XMLNAMESPACES
The following query explicitly defines the namespace prefix to URI binding for the predefined namespace ( urn:schemas-microsoft-com:xml-sql ).
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