Comments (3)
To note the further issue this causes is that when you name a column on a micronaut-data entity something like @column(name = "_my_column_name")
it will not select the right column in querying and causes issues, which you can't fix without changing the naming strategy
from micronaut-core.
For those who run into this issue, you can override the PhysicalNamingStrategy like this with the fix in it.
package com.trynow.micronaut
import io.micronaut.context.annotation.Primary
import io.micronaut.context.annotation.Replaces
import io.micronaut.data.hibernate.naming.DefaultPhysicalNamingStrategy
import io.micronaut.data.model.naming.NamingStrategy
import jakarta.inject.Singleton
import org.hibernate.boot.model.naming.Identifier
import org.hibernate.boot.model.naming.PhysicalNamingStrategy
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment
/***
* This is an almost exact copy of the DefaultPhysicalNamingStrategy class with a fix for a bug
* that occurs when an identifier start with an underscore.
*/
@Singleton
@Primary
@Replaces(DefaultPhysicalNamingStrategy::class)
class PhysicalNamingStrategyCustom : PhysicalNamingStrategy {
override fun toPhysicalCatalogName(name: Identifier?, jdbcEnvironment: JdbcEnvironment?): Identifier? {
return getIdentifier(name)
}
override fun toPhysicalSchemaName(name: Identifier?, jdbcEnvironment: JdbcEnvironment?): Identifier? {
return getIdentifier(name)
}
override fun toPhysicalTableName(name: Identifier?, jdbcEnvironment: JdbcEnvironment?): Identifier? {
return getIdentifier(name)
}
override fun toPhysicalSequenceName(name: Identifier?, jdbcEnvironment: JdbcEnvironment?): Identifier? {
return getIdentifier(name)
}
override fun toPhysicalColumnName(name: Identifier?, jdbcEnvironment: JdbcEnvironment?): Identifier? {
name?.let {
// In this case the getIdentifier code causes double underscore to be prepended to a string,
// so we just return the original name, and we will just handle that column name more explicitly
if (name.text.startsWith("_")) {
return name
}
}
return getIdentifier(name)
}
private fun getIdentifier(name: Identifier?): Identifier? {
return if (name == null) {
null
} else {
Identifier(
NamingStrategy.DEFAULT.mappedName(name.text),
name.isQuoted
)
}
}
}
from micronaut-core.
underscoreSeparate("_nameOfThing") should result in "_name_of_thing" but actually results in "__name_of_thing"
Actually, the expected result should be _name_Of_Thing
because the NameUtils.underscoreSeparate
does not perform lowercase. I will overload the call to support it with underscoreSeparate(String camelCase, boolean lowercase)
from micronaut-core.
Related Issues (20)
- Update to Kotlin 2.0
- Update to Groovy 5.0 HOT 1
- JacksonConfiguration.constructType throws ArrayIndexOutOfBoundsException for an Argument created from ParenthesizedType like Map<String,String> HOT 1
- NoSuchBeanException: No bean of type [io.netty.bootstrap.ServerBootstrap] exists HOT 1
- @Slf4j breaks with cache annotations HOT 2
- @EachProperty with abstract class override + KSP does not compile
- Micronaut mixes up a qualified bean from unqualified one when @Replace is used HOT 4
- Implementing Lazy initialized Bean @Lazy HOT 4
- AnnotationMetadata is empty when we use Optional HOT 2
- Netty DefaultHttpClient logs "BUG - Handler not removed" after adding logbook HOT 1
- Errors On Main Web Site HOT 4
- @Mapper not working for lists
- Rejected auth shouldn't lead to "UnexpectedError" being logged with Error level
- Exception implementing HttpResponseProvider thrown from Controller endpoint shouldn't lead to "Unexpected Error" Error log
- Annotation Processor NPE HOT 7
- @Scheduled does not work with expressions in cron value HOT 3
- ./gradlew buildNativeLambda fails due to logback build time init when using dynamodb feature -> Error: Classes that should be initialized at run time got initialized during image building ->
- Introspection Compilation broken for byte[] types that are constructor arguments
- AWSParameterStoreConfigClient Inconsistence with documentation
- Evaluated expressions not working in all annotations they should be (ex: `io.micrometer.core.annotation.Timed`)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micronaut-core.