Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Column not processed as expected regarding updatable #13

Open
ChristianSch opened this issue Jul 9, 2020 · 1 comment
Open

@Column not processed as expected regarding updatable #13

ChristianSch opened this issue Jul 9, 2020 · 1 comment

Comments

@ChristianSch
Copy link
Contributor

Hi guys,

Using the aforementioned annotation (as you do in the examples) with @Column(updatable=false) doesn't do anything.

@Entity
data class Customer(
        @Id
        val uuid: UUID = UUID.randomUUID(),

        val email: String,

        @Column(updatable = false)
        val name: String,

        @Embedded
        var address: CustomerAddress = CustomerAddress(),

        var groupId: String?
)

generates the following mapping (mapping.kt):

fun UpdateBuilder<Any>.from(customer: Customer) {
  	this[CustomerTable.uuid] = customer.uuid
  	this[CustomerTable.email] = customer.email
  	this[CustomerTable.name] = customer.name
  	this[CustomerTable.groupId] = customer.groupId
  	this[CustomerTable.addressCity] = customer.address.city
  	this[CustomerTable.addressCountry] = customer.address.country
  	this[CustomerTable.addressLine1] = customer.address.line1
  	this[CustomerTable.addressLine2] = customer.address.line2
  	this[CustomerTable.addressPostalCode] = customer.address.postalCode
  	this[CustomerTable.addressState] = customer.address.state
}

I expect the uuid and the name to not be included in this generated update mapping.

So it would be nice to either have documentation on what you actually process (found it here indirectly though). I feel like it's weird behaviour btw that I can just update an id after creation. My question is: can I somehow prevent updating with krush? If not, would it be something you'd consider implementing?

@pjagielski
Copy link
Collaborator

Hi, thanks for the submission.
For now we support @Transient annotation which prevents property from either read or update.
updatable=false seems like a good feature to implement - I'll keep the issue open to track the progress.
Sure, id should not be in the UpdateBuilder - we'll check this as well.

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

No branches or pull requests

2 participants