-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat(server): support float fields #1263
Changes from 8 commits
b4d71c5
c767965
dff1875
623882b
7afadf4
5102f66
5ddba4e
65d2313
d5a10fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1450,7 +1450,7 @@ func TestIntegrationModelImportJSONWithJsonInput(t *testing.T) { | |
mId, _ := createModel(e, pId, "test", "test", "test-1") | ||
createFieldOfEachType(t, e, mId) | ||
|
||
jsonContent := `[{"text": "test1", "bool": true, "integer": 1},{"text": "test2", "bool": false, "integer": 2},{"text": "test3", "bool": null, "integer": null}]` | ||
jsonContent := `[{"text": "test1", "bool": true, "number": 1.1},{"text": "test2", "bool": false, "number": 2},{"text": "test3", "bool": null, "number": null}]` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Action Required: Update Remaining "integer" References to "number" The search revealed multiple instances of
This will help prevent potential type mismatches and ensure seamless functionality across the system. 🔗 Analysis chainLGTM! Consider verifying the impact of the field type change. The change from "integer" to "number" in the test JSON content is good and reflects the new support for floating-point numbers. This update aligns the test case with the new field structure. To ensure this change doesn't have unintended consequences, please run the following script to check for any other occurrences of "integer" fields that might need updating: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for other occurrences of "integer" fields in the codebase
rg '"integer"' --type go
Length of output: 1553 |
||
aId := UploadAsset(e, pId, "./test1.json", jsonContent).Object().Value("id").String().Raw() | ||
res := IntegrationModelImportJSON(e, mId, aId, "json", "insert", false, nil) | ||
res.Object().IsEqual(map[string]any{ | ||
|
@@ -1573,7 +1573,7 @@ func TestIntegrationItemsAsCSV(t *testing.T) { | |
}) | ||
|
||
res := IntegrationItemsAsCSV(e, mId, 1, 10, i1Id, "", "", nil) | ||
expected := fmt.Sprintf("id,location_lat,location_lng,text,textArea,markdown,asset,bool,select,integer,url,date,tag,checkbox\n%s,139.28179282584915,36.58570985749664,test1,,,,,,,,,,\n", i1Id) | ||
expected := fmt.Sprintf("id,location_lat,location_lng,text,textArea,markdown,asset,bool,select,integer,number,url,date,tag,checkbox\n%s,139.28179282584915,36.58570985749664,test1,,,,,,,,,,,\n", i1Id) | ||
res.IsEqual(expected) | ||
} | ||
|
||
|
@@ -1593,7 +1593,7 @@ func TestIntegrationItemsWithProjectAsCSV(t *testing.T) { | |
}) | ||
|
||
res := IntegrationItemsWithProjectAsCSV(e, pId, mId, 1, 10, i1Id, "", "", nil) | ||
expected := fmt.Sprintf("id,location_lat,location_lng,text,textArea,markdown,asset,bool,select,integer,url,date,tag,checkbox\n%s,139.28179282584915,36.58570985749664,test1,,,,,,30,,,,\n", i1Id) | ||
expected := fmt.Sprintf("id,location_lat,location_lng,text,textArea,markdown,asset,bool,select,integer,number,url,date,tag,checkbox\n%s,139.28179282584915,36.58570985749664,test1,,,,,,30,,,,,\n", i1Id) | ||
res.IsEqual(expected) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,6 +177,52 @@ func TestIntegrationFieldCreateAPI(t *testing.T) { | |
|
||
res.ContainsKey("id") | ||
|
||
res = e.GET("/api/models/{modelId}", mId1). | ||
WithHeader("authorization", "Bearer "+secret). | ||
Expect(). | ||
Status(http.StatusOK). | ||
JSON(). | ||
Object() | ||
|
||
res.ContainsSubset(map[string]any{ | ||
"name": "m1", | ||
"id": mId1.String(), | ||
"description": "m1 desc", | ||
"public": true, | ||
"key": ikey1.String(), | ||
"projectId": pid, | ||
"schemaId": sid1, | ||
}) | ||
|
||
res.Value("createdAt").NotNull() | ||
res.Value("updatedAt").NotNull() | ||
res.Value("lastModified").NotNull() | ||
resf := res.Value("schema").Object().Value("fields").Array() | ||
resf.Length().IsEqual(3) | ||
resf.Value(2).Object().ContainsSubset(map[string]any{ | ||
// "id": "", // generated | ||
"key": "テスト", | ||
"type": "text", | ||
"required": false, | ||
}) | ||
// endregion | ||
Comment on lines
+180
to
+208
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider making field verification more robust The current test relies on hardcoded array indices (e.g., - resf.Value(2).Object().ContainsSubset(map[string]any{
- "key": "テスト",
- "type": "text",
- "required": false,
- })
+ // Add helper function
+ func findFieldByKey(fields *httpexpect.Array, key string) *httpexpect.Object {
+ for i := 0; i < fields.Length().Raw(); i++ {
+ field := fields.Value(i).Object()
+ if field.Value("key").String().Raw() == key {
+ return field
+ }
+ }
+ return nil
+ }
+
+ // Use helper in test
+ findFieldByKey(resf, "テスト").ContainsSubset(map[string]any{
+ "key": "テスト",
+ "type": "text",
+ "required": false,
+ })
|
||
|
||
//region bool | ||
res = e.POST(endpoint, sid1). | ||
WithHeader("authorization", "Bearer "+secret). | ||
WithJSON(map[string]interface{}{ | ||
"key": "fKey1", | ||
"type": "bool", | ||
"multiple": false, | ||
"required": false, | ||
}). | ||
Expect(). | ||
Status(http.StatusOK). | ||
JSON(). | ||
Object() | ||
|
||
res.ContainsKey("id") | ||
|
||
res = e.GET("/api/models/{modelId}", mId1). | ||
WithHeader("authorization", "Bearer "+secret). | ||
Expect(). | ||
|
@@ -192,18 +238,25 @@ func TestIntegrationFieldCreateAPI(t *testing.T) { | |
HasValue("projectId", pid). | ||
HasValue("schemaId", sid1) | ||
|
||
res.Value("schema").Object().Value("fields").Array().Length().IsEqual(3) | ||
res.Value("createdAt").NotNull() | ||
res.Value("updatedAt").NotNull() | ||
res.Value("lastModified").NotNull() | ||
resf = res.Value("schema").Object().Value("fields").Array() | ||
resf.Length().IsEqual(4) | ||
resf.Value(3).Object().ContainsSubset(map[string]any{ | ||
// "id": "", // generated | ||
"key": "fKey1", | ||
"type": "bool", | ||
"required": false, | ||
}) | ||
// endregion | ||
|
||
//region bool | ||
//region number | ||
res = e.POST(endpoint, sid1). | ||
WithHeader("authorization", "Bearer "+secret). | ||
WithJSON(map[string]interface{}{ | ||
"key": "fKey1", | ||
"type": "bool", | ||
"key": "fKey2", | ||
"type": "number", | ||
"multiple": false, | ||
"required": false, | ||
}). | ||
|
@@ -229,17 +282,24 @@ func TestIntegrationFieldCreateAPI(t *testing.T) { | |
HasValue("projectId", pid). | ||
HasValue("schemaId", sid1) | ||
|
||
res.Value("schema").Object().Value("fields").Array().Length().IsEqual(4) | ||
res.Value("createdAt").NotNull() | ||
res.Value("updatedAt").NotNull() | ||
res.Value("lastModified").NotNull() | ||
resf = res.Value("schema").Object().Value("fields").Array() | ||
resf.Length().IsEqual(5) | ||
resf.Value(4).Object().ContainsSubset(map[string]any{ | ||
// "id": "", // generated | ||
"key": "fKey2", | ||
"type": "number", | ||
"required": false, | ||
}) | ||
// endregion | ||
|
||
// region GeoObject | ||
res = e.POST(endpoint, sid1). | ||
WithHeader("authorization", "Bearer "+secret). | ||
WithJSON(map[string]interface{}{ | ||
"key": "fKey2", | ||
"key": "fKey3", | ||
"type": "geometryObject", | ||
"multiple": false, | ||
"required": false, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider adding tests for the "number" field's constraints
While the "number" field is properly added, consider adding tests to validate its
defaultValue
,min
, andmax
properties to ensure it behaves correctly under various conditions.