From 59aa5c0f8b88914286be910c1711af2abc4d33e8 Mon Sep 17 00:00:00 2001 From: miyamo2 <79917704+miyamo2@users.noreply.github.com> Date: Sat, 11 May 2024 15:21:59 +0900 Subject: [PATCH] Rename the key name of tag, dynmgrm:lsi to dynmgrm:lsi-sk (#108) --- .docs/MIGRATION.md | 4 ++-- migrator_test.go | 2 +- reflect_helper.go | 2 +- reflect_helper_test.go | 4 ++-- tests/create_table_test.go | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.docs/MIGRATION.md b/.docs/MIGRATION.md index cbcbe50..d8df9b0 100644 --- a/.docs/MIGRATION.md +++ b/.docs/MIGRATION.md @@ -8,7 +8,7 @@ package main type User struct { ProjectID string `gorm:"primaryKey dynmgrm:"pk"` ID string `gorm:"primaryKey dynmgrm:"sk;gsi-pk:id_name-index"` - Name string `dynmgrm:"gsi-sk:id_name-index;lsi:name-index"` + Name string `dynmgrm:"gsi-sk:id_name-index;lsi-sk:name-index"` Note string `dynmgrm:"non-projective:[id_name-index,name-index]"` } ``` @@ -21,5 +21,5 @@ type User struct { | sk | - | field will be the SK attribute of the table. | | gsi-pk | :\ | field will be the PK attribute of the specified Global Secondary Index.
It works with `Migrator.CreateIndex()` | | gsi-sk | :\ | field will be the SK attribute of the specified Global Secondary Index.
It works with `Migrator.CreateIndex()` | -| lsi | :\ | field will be the SK attribute of the specified Local Secondary Index. | +| lsi-sk | :\ | field will be the SK attribute of the specified Local Secondary Index. | | non-projective | :[(,)\] | exclude from projection at enumerated Index. | diff --git a/migrator_test.go b/migrator_test.go index dac3a17..c237b4e 100644 --- a/migrator_test.go +++ b/migrator_test.go @@ -95,7 +95,7 @@ var ( type CreateTableATable struct { PK string `dynmgrm:"pk"` SK int `dynmgrm:"sk"` - LsiSK []byte `dynmgrm:"lsi:lsi_sk-index"` + LsiSK []byte `dynmgrm:"lsi-sk:lsi_sk-index"` ProjectiveAttr1 string ProjectiveAttr2 string NonProjective string `dynmgrm:"non-projective:[lsi_sk-index]"` diff --git a/reflect_helper.go b/reflect_helper.go index f556c05..01f19e9 100644 --- a/reflect_helper.go +++ b/reflect_helper.go @@ -110,7 +110,7 @@ func newDynmgrmTag(tag reflect.StructTag) dynmgrmTag { Kind: secondaryIndexKindGSI, } res.IndexProperty = append(res.IndexProperty, iprp) - case "lsi": + case "lsi-sk": iprp := secondaryIndexProperty{ Name: kv[1], SK: true, diff --git a/reflect_helper_test.go b/reflect_helper_test.go index e8905f7..88717de 100644 --- a/reflect_helper_test.go +++ b/reflect_helper_test.go @@ -251,7 +251,7 @@ func Test_newDynmgrmTag(t *testing.T) { B string `dynmgrm:"sk"` C string `dynmgrm:"gsi-pk:c_d-index"` D string `dynmgrm:"gsi-sk:c_d-index"` - E string `dynmgrm:"lsi:e-index"` + E string `dynmgrm:"lsi-sk:e-index"` F string `dynmgrm:"non-projective:[c_d-index,e-index]"` G string `dynmgrm:"pk;sk"` H string `dynmgrm:"sk;pk"` @@ -373,7 +373,7 @@ func Test_newDynmgrmTableDefine(t *testing.T) { B string `dynmgrm:"sk"` C string `dynmgrm:"gsi-pk:c_d-index"` D string `dynmgrm:"gsi-sk:c_d-index"` - E string `dynmgrm:"lsi:e-index"` + E string `dynmgrm:"lsi-sk:e-index"` F string `dynmgrm:"non-projective:[c_d-index,e-index]"` } type test struct { diff --git a/tests/create_table_test.go b/tests/create_table_test.go index 4ca51f1..ecf50f1 100644 --- a/tests/create_table_test.go +++ b/tests/create_table_test.go @@ -84,7 +84,7 @@ func Test_CreateTable(t *testing.T) { type CreateTableTestWithLSITable struct { PK string `dynmgrm:"pk"` SK int `dynmgrm:"sk"` - Name string `dynmgrm:"lsi:pk-name-index"` + Name string `dynmgrm:"lsi-sk:pk-name-index"` Projective string NonProjective string `dynmgrm:"non-projective:[pk-name-index]"` }