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

During the connection process, if a table field has been added, it is not possible to update the newly added field's data using g.Model(tableName).Data(newData).Update(). #3654

Closed
leavky opened this issue Jun 20, 2024 · 2 comments
Labels

Comments

@leavky
Copy link

leavky commented Jun 20, 2024

Go version

go1.21.5

GoFrame version

v2.7.0

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

开启服务,使用ALTER TABLE tableName ADD COLUMN fieldName TEXT; 为表格添加一个新的字段,然后通过g.Model(tableName ).Where("id", recordId).OmitEmpty().Data(newData).Update() 无法更新数据,但是新增字段后重启服务,使用g.Model(tableName ).Where("id", recordId).OmitEmpty().Data(newData).Update() 就可以更新数据了

What did you see happen?

通过g.Model(tableName ).Where("id", recordId).OmitEmpty().Data(newData).Update() 无法更新数据

What did you expect to see?

新增字段后可以通过通过g.Model(tableName ).Where("id", recordId).OmitEmpty().Data(newData).Update() 更新数据,目前使用执行SQL语句解决了,希望可以修正一下在运行过程中增加了字段也可以更新数据

@leavky leavky added the bug It is confirmed a bug, but don't worry, we'll handle it. label Jun 20, 2024
@oldme-git oldme-git added question and removed bug It is confirmed a bug, but don't worry, we'll handle it. labels Jun 21, 2024
@oldme-git
Copy link
Member

g.Model() 是一个单例对象,并只会初始化一次 DB 对象,所以这并不是一个 Bug。如果你想在更新字段后操作数据库,可以自行维护一个 gdb 对象

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


g.Model() is a singleton object and will only initialize the DB object once, so this is not a Bug. If you want to operate the database after updating the fields, you can maintain a gdb object yourself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants