Skip to content

Commit

Permalink
remove unused codes
Browse files Browse the repository at this point in the history
  • Loading branch information
amirrezaask committed Apr 9, 2022
1 parent 79faad8 commit d73d1e5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 58 deletions.
46 changes: 0 additions & 46 deletions field.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,6 @@ type field struct {
Type reflect.Type
}

type fieldTag struct {
Name string
Virtual bool
PK bool
Nullable bool
Default string
IsCreatedAt bool
IsUpdatedAt bool
IsDeletedAt bool
}

func fieldMetadataFromTag(t string) fieldTag {
if t == "" {
return fieldTag{}
}
tuples := strings.Split(t, " ")
var tag fieldTag
for _, tuple := range tuples {
parts := strings.Split(tuple, "=")
key := parts[0]
value := parts[1]
if key == "col" {
tag.Name = value
} else if key == "pk" {
tag.PK = true
} else if key == "created_at" {
tag.IsCreatedAt = true
} else if key == "updated_at" {
tag.IsUpdatedAt = true
} else if key == "deleted_at" {
tag.IsDeletedAt = true
} else if key == "nullable" {
tag.Nullable = true
} else if key == "default" {
tag.Default = value
}
if tag.Name == "_" {
tag.Virtual = true
}
}
return tag
}
func getFieldConfiguratorFor(fieldConfigurators []*FieldConfigurator, name string) *FieldConfigurator {
for _, fc := range fieldConfigurators {
if fc.fieldName == name {
Expand All @@ -71,7 +29,6 @@ func getFieldConfiguratorFor(fieldConfigurators []*FieldConfigurator, name strin
}

func fieldMetadata(ft reflect.StructField, fieldConfigurators []*FieldConfigurator) []*field {
// tagParsed := fieldMetadataFromTag(ft.Tag.Get("orm"))
var fms []*field
fc := getFieldConfiguratorFor(fieldConfigurators, ft.Name)
baseFm := &field{}
Expand All @@ -94,9 +51,6 @@ func fieldMetadata(ft reflect.StructField, fieldConfigurators []*FieldConfigurat
if strings.ToLower(ft.Name) == "deletedat" || fc.isDeletedAt {
baseFm.IsDeletedAt = true
}
// if tagParsed.Virtual {
// baseFm.Virtual = true
// }
if ft.Type.Kind() == reflect.Struct || ft.Type.Kind() == reflect.Ptr {
t := ft.Type
if ft.Type.Kind() == reflect.Ptr {
Expand Down
13 changes: 1 addition & 12 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package orm

import (
"fmt"
"reflect"
)

func postgresPlaceholder(n int) []string {
Expand All @@ -20,14 +19,4 @@ func questionMarks(n int) []string {
}

return output
}

func entitiesAsList(entities []Entity) []string {
var output []string

for _, entity := range entities {
output = append(output, reflect.TypeOf(entity).Elem().Name())
}

return output
}
}

0 comments on commit d73d1e5

Please sign in to comment.