You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am getting the following error while using Update method even though created_at field of type datetime is not explicitly modified anywhere.
There was a problem with the database: Found changed value for field `created_at`, with record `location:boisar`, but field is readonly
Steps to reproduce
My table is defined as below:
DEFINE TABLE location SCHEMAFULL;
DEFINE FIELD name ON location TYPE string;
DEFINE FIELD address ON location TYPE string;
DEFINE FIELD city ON location TYPE string;
DEFINE FIELD state ON location TYPE string;
DEFINE FIELD country ON location TYPE string;
DEFINE FIELD postal_code ON location TYPE string;
DEFINE FIELD created_at ON location TYPE datetime DEFAULT time::now() READONLY;
DEFINE FIELD updated_at ON location TYPE datetime VALUE time::now();
My struct is below:
type Location struct {
ID *models.RecordID `json:"id,omitempty"`
Name string `json:"name"`
Address string `json:"address"`
City string `json:"city"`
State string `json:"state"`
Country string `json:"country"`
PostalCode string `json:"postal_code"`
}
@tobiemh I am using the nightly build of surrealdb and this issue is solved. Thanks for your help. But I have a very serious concern about the go SDK latest version i.e. 0.3. It has lots of short comings compared to the previous version i.e. 0.2. The previous one was much more flexible. Please ponder on the following example:
In the latest one I wrote a func like this which is failing
func (a Attribute) GetAll(sp myconst.SearchParam, whereQry string) (interface{}, error) {
if whereQry == "" {
whereQry = "1"
}
query := fmt.Sprintf("SELECT *, unit.* FROM %s WHERE %s", myconst.TableAttribute, whereQry)
search := sp.Search
if search != "" {
query += fmt.Sprintf(
" AND (string::lowercase(name || '') CONTAINS string::lowercase('%s') OR "+
"string::lowercase(unit.name || '') CONTAINS string::lowercase('%s') OR "+
"string::lowercase(data_type || '') CONTAINS string::lowercase('%s'))",
search, search, search,
)
}
if sp.Sort != "" {
sort := sp.Sort + " ASC"
if sp.Desc {
sort = sort + " DESC"
}
query += " ORDER BY " + sort
}
if sp.Limit > 0 && sp.Start >= 0 {
query += fmt.Sprintf(" LIMIT %d START %d", sp.Limit, sp.Start)
}
res, err := surrealdb.Query[[]AttributeResponse](db.DB, query, nil)
if err != nil {
return nil, err
}
return PaginatedResponse{
Result: (*res)[0].Result,
Total: GetTotalCount(a.TableName()),
}, nil
}
The the latest version is not allowing just to return interface{}. Also another serious concern is mentioned in the bug above CBOR is hindering the performance of all methods unnecessarily. I really also don't understand and like the introduction of models.RecordID and models.CustomeDateTime fields as all structs are expecting record id of that type which is bad.
Describe the bug
I am getting the following error while using
Update
method even thoughcreated_at
field of typedatetime
is not explicitly modified anywhere.Steps to reproduce
My table is defined as below:
My struct is below:
The
Update
function is called as below:I am getting the following error:
Expected behaviour
Update should execute successfully without complaining about
created_at
field.SurrealDB version
surreal 2.0.4, surrealdb.go 0.3.0 and 1.0.0-beta, windows 11
Contact Details
[email protected]
Is there an existing issue for this?
Code of Conduct
The text was updated successfully, but these errors were encountered: