From 37d19b4b708065a77381c0985dea3122a44b0472 Mon Sep 17 00:00:00 2001 From: Nima Sarayan Date: Fri, 27 Feb 2026 18:29:45 +0330 Subject: [PATCH] refactor: welcome to the trixorm era --- background_consumer.go | 2 +- background_consumer_test.go | 6 +++--- bind_builder.go | 2 +- cached_search.go | 2 +- cached_search_test.go | 14 +++++++------- clear_by_ids.go | 2 +- db.go | 2 +- db_test.go | 2 +- dirty_event.go | 2 +- dirty_test.go | 2 +- engine.go | 2 +- engine_test.go | 2 +- entity_redis_search.go | 2 +- entity_redis_search_test.go | 22 +++++++++++----------- event_broker.go | 2 +- event_broker_test.go | 2 +- flusher.go | 2 +- flusher_test.go | 24 ++++++++++++------------ global_test.go | 11 +++-------- load_by_id.go | 2 +- load_by_id_test.go | 6 +++--- load_by_ids.go | 2 +- load_by_ids_test.go | 6 +++--- local_cache.go | 2 +- local_cache_test.go | 2 +- locker.go | 2 +- locker_test.go | 2 +- log_consumer_test.go | 2 +- orm.go | 2 +- orm_test.go | 2 +- pager.go | 2 +- pager_test.go | 2 +- query_logger.go | 6 +++--- redis_cache.go | 2 +- redis_cache_test.go | 2 +- redis_flusher.go | 2 +- redis_flusher_test.go | 2 +- redis_pipeline.go | 2 +- redis_pipeline_test.go | 2 +- redis_search.go | 2 +- redis_search_indexer.go | 2 +- redis_search_test.go | 2 +- registry.go | 2 +- request_cache_test.go | 2 +- schema.go | 4 ++-- schema_test.go | 24 ++++++++++++------------ search.go | 4 ++-- search_test.go | 4 ++-- serializer.go | 2 +- table_schema.go | 6 +++--- tools/redis_search_statistic_test.go | 10 +++++----- tools/redis_search_statistics.go | 2 +- tools/redis_statistic_test.go | 4 ++-- tools/redis_statistics.go | 2 +- tools/redis_streams_statistics.go | 2 +- tools/redis_streams_statistics_test.go | 2 +- uuid.go | 2 +- uuid_test.go | 2 +- validated_registry.go | 2 +- validated_registry_test.go | 6 +++--- where.go | 2 +- where_test.go | 2 +- yaml_loader.go | 2 +- yaml_loader_test.go | 2 +- 64 files changed, 124 insertions(+), 129 deletions(-) diff --git a/background_consumer.go b/background_consumer.go index e2f14d6..4ae5c7c 100644 --- a/background_consumer.go +++ b/background_consumer.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" diff --git a/background_consumer_test.go b/background_consumer_test.go index 2849b3a..98174b6 100644 --- a/background_consumer_test.go +++ b/background_consumer_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" @@ -13,7 +13,7 @@ type lazyReceiverEntity struct { ID uint Name string `orm:"unique=name"` Age uint64 - EnumNullable string `orm:"enum=beeorm.TestEnum"` + EnumNullable string `orm:"enum=trixorm.TestEnum"` RefOne *lazyReceiverReference IndexAll *CachedQuery `query:""` } @@ -29,7 +29,7 @@ func TestBackgroundConsumer(t *testing.T) { var ref *lazyReceiverReference registry := &Registry{} - registry.RegisterEnum("beeorm.TestEnum", []string{"a", "b", "c"}) + registry.RegisterEnum("trixorm.TestEnum", []string{"a", "b", "c"}) engine, def := prepareTables(t, registry, 5, "", "2.0", entity, ref) defer def() engine.GetRedis().FlushDB() diff --git a/bind_builder.go b/bind_builder.go index b193f8e..76f34a5 100644 --- a/bind_builder.go +++ b/bind_builder.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "fmt" diff --git a/cached_search.go b/cached_search.go index 1899f83..cc23a6e 100644 --- a/cached_search.go +++ b/cached_search.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "fmt" diff --git a/cached_search_test.go b/cached_search_test.go index 9a6076f..7284060 100644 --- a/cached_search_test.go +++ b/cached_search_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" @@ -226,7 +226,7 @@ func testCachedSearch(t *testing.T, localCache bool, redisCache bool) { assert.PanicsWithError(t, "reference WrongReference in cachedSearchEntity is not valid", func() { engine.CachedSearchWithReferences(&rows, "IndexAge", nil, []interface{}{10}, []string{"WrongReference"}) }) - assert.PanicsWithError(t, "interface *beeorm.cachedSearchEntity is no slice of beeorm.Entity", func() { + assert.PanicsWithError(t, "interface *trixorm.cachedSearchEntity is no slice of trixorm.Entity", func() { engine.CachedSearchWithReferences(entity, "IndexAge", nil, []interface{}{10}, []string{"WrongReference"}) }) @@ -269,11 +269,11 @@ func TestCachedSearchErrors(t *testing.T) { engine, def := prepareTables(t, &Registry{}, 5, "", "2.0") defer def() var rows []*cachedSearchEntity - assert.PanicsWithError(t, "entity 'beeorm.cachedSearchEntity' is not registered", func() { + assert.PanicsWithError(t, "entity 'trixorm.cachedSearchEntity' is not registered", func() { _ = engine.CachedSearch(&rows, "IndexAge", nil, 10) }) var row cachedSearchEntity - assert.PanicsWithError(t, "entity 'beeorm.cachedSearchEntity' is not registered", func() { + assert.PanicsWithError(t, "entity 'trixorm.cachedSearchEntity' is not registered", func() { _ = engine.CachedSearchOne(&row, "IndexName", 10) }) @@ -295,12 +295,12 @@ func TestCachedSearchErrors(t *testing.T) { }) var rows2 []*cachedSearchRefEntity - assert.PanicsWithError(t, "cache search not allowed for entity without cache: 'beeorm.cachedSearchRefEntity'", func() { + assert.PanicsWithError(t, "cache search not allowed for entity without cache: 'trixorm.cachedSearchRefEntity'", func() { _ = engine.CachedSearch(&rows2, "IndexAll", nil, 10) }) var row2 cachedSearchRefEntity - assert.PanicsWithError(t, "cache search not allowed for entity without cache: 'beeorm.cachedSearchRefEntity'", func() { + assert.PanicsWithError(t, "cache search not allowed for entity without cache: 'trixorm.cachedSearchRefEntity'", func() { _ = engine.CachedSearchOne(&row2, "IndexName", 10) }) } @@ -309,7 +309,7 @@ func BenchmarkCachedSearch(b *testing.B) { entity := &schemaEntity{} ref := &schemaEntityRef{} registry := &Registry{} - registry.RegisterEnumStruct("beeorm.TestEnum", TestEnum) + registry.RegisterEnumStruct("trixorm.TestEnum", TestEnum) registry.RegisterLocalCache(10000) engine, def := prepareTables(nil, registry, 5, "", "2.0", entity, ref) defer def() diff --git a/clear_by_ids.go b/clear_by_ids.go index 659466d..c9ba054 100644 --- a/clear_by_ids.go +++ b/clear_by_ids.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm func clearByIDs(engine *Engine, entity Entity, ids ...uint64) { schema := initIfNeeded(engine.registry, entity).tableSchema diff --git a/db.go b/db.go index 511c72e..a3a724e 100644 --- a/db.go +++ b/db.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" diff --git a/db_test.go b/db_test.go index f171bad..d7e2381 100644 --- a/db_test.go +++ b/db_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "database/sql" diff --git a/dirty_event.go b/dirty_event.go index dc9d32e..c5ea57f 100644 --- a/dirty_event.go +++ b/dirty_event.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm type DirtyEntityEvent interface { ID() uint64 diff --git a/dirty_test.go b/dirty_test.go index 7254d58..33a17d1 100644 --- a/dirty_test.go +++ b/dirty_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" diff --git a/engine.go b/engine.go index 5b0b957..7306c9d 100644 --- a/engine.go +++ b/engine.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" diff --git a/engine_test.go b/engine_test.go index aaa3168..6924fc1 100644 --- a/engine_test.go +++ b/engine_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "testing" diff --git a/entity_redis_search.go b/entity_redis_search.go index 402ee95..3b7601e 100644 --- a/entity_redis_search.go +++ b/entity_redis_search.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "fmt" diff --git a/entity_redis_search_test.go b/entity_redis_search_test.go index ff442d9..b59673d 100644 --- a/entity_redis_search_test.go +++ b/entity_redis_search_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" @@ -18,12 +18,12 @@ type redisSearchEntity struct { Weight float64 `orm:"searchable"` AgeNullable *uint64 `orm:"searchable;sortable"` BalanceNullable *int64 `orm:"searchable;sortable"` - Enum string `orm:"enum=beeorm.TestEnum;required;searchable"` - EnumNullable string `orm:"enum=beeorm.TestEnum;searchable"` + Enum string `orm:"enum=trixorm.TestEnum;required;searchable"` + EnumNullable string `orm:"enum=trixorm.TestEnum;searchable"` Name string `orm:"searchable"` NameStem string `orm:"searchable;stem"` - Set []string `orm:"set=beeorm.TestEnum;required;searchable"` - SetNullable []string `orm:"set=beeorm.TestEnum;searchable"` + Set []string `orm:"set=trixorm.TestEnum;required;searchable"` + SetNullable []string `orm:"set=trixorm.TestEnum;searchable"` Bool bool `orm:"searchable;sortable"` BoolNullable *bool `orm:"searchable"` WeightNullable *float64 `orm:"searchable"` @@ -89,7 +89,7 @@ func TestEntityRedisSearchIndexerNamespace(t *testing.T) { func testEntityRedisSearchIndexer(t *testing.T, redisNamespace, version string) { var entity *redisSearchEntity registry := &Registry{} - registry.RegisterEnumStruct("beeorm.TestEnum", TestEnum) + registry.RegisterEnumStruct("trixorm.TestEnum", TestEnum) engine, def := prepareTables(t, registry, 5, redisNamespace, version, entity, &redisNoSearchEntity{}) defer def() indexer := NewBackgroundConsumer(engine) @@ -130,7 +130,7 @@ func testEntityRedisSearchIndexer(t *testing.T, redisNamespace, version string) func TestEntityRedisSearchIndexerNoFakeDelete(t *testing.T) { var entity *redisSearchEntityNoSearchableFakeDelete registry := &Registry{} - registry.RegisterEnumStruct("beeorm.TestEnum", TestEnum) + registry.RegisterEnumStruct("trixorm.TestEnum", TestEnum) engine, def := prepareTables(t, registry, 5, "", "2.0", entity) defer def() indexer := NewBackgroundConsumer(engine) @@ -179,7 +179,7 @@ func TestEntityRedisSearchNamespace(t *testing.T) { func testEntityRedisSearch(t *testing.T, redisNamespace string) { var entity *redisSearchEntity registry := &Registry{} - registry.RegisterEnumStruct("beeorm.TestEnum", TestEnum) + registry.RegisterEnumStruct("trixorm.TestEnum", TestEnum) engine, def := prepareTables(t, registry, 5, redisNamespace, "2.0", entity, &redisNoSearchEntity{}, &redisNoSearchEntity{}) alters := engine.GetRedisSearchIndexAlters() @@ -256,7 +256,7 @@ func testEntityRedisSearch(t *testing.T, redisNamespace string) { indices := engine.GetRedisSearch("search").ListIndices() assert.Len(t, indices, 1) - assert.Equal(t, "beeorm.redisSearchEntity", indices[0]) + assert.Equal(t, "trixorm.redisSearchEntity", indices[0]) info := engine.GetRedisSearch("search").Info(indices[0]) assert.False(t, info.Indexing) assert.True(t, info.Options.NoFreqs) @@ -267,7 +267,7 @@ func testEntityRedisSearch(t *testing.T, redisNamespace string) { if redisNamespace != "" { prefix = redisNamespace + ":" } - assert.Equal(t, []string{prefix + "7499e:"}, info.Definition.Prefixes) + assert.Equal(t, []string{prefix + "554dd:"}, info.Definition.Prefixes) assert.Len(t, info.Fields, 25) assert.Equal(t, "ID", info.Fields[0].Name) assert.Equal(t, "NUMERIC", info.Fields[0].Type) @@ -1094,7 +1094,7 @@ func testEntityRedisSearch(t *testing.T, redisNamespace string) { engine.RedisSearch(&[]*string{}, query, NewPager(1, 100)) }) - assert.PanicsWithError(t, "entity beeorm.redisNoSearchEntity is not searchable", func() { + assert.PanicsWithError(t, "entity trixorm.redisNoSearchEntity is not searchable", func() { query = &RedisSearchQuery{} engine.RedisSearch(&[]*redisNoSearchEntity{}, query, NewPager(1, 100)) }) diff --git a/event_broker.go b/event_broker.go index 6cbf96b..367e438 100644 --- a/event_broker.go +++ b/event_broker.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" diff --git a/event_broker_test.go b/event_broker_test.go index c014158..b253221 100644 --- a/event_broker_test.go +++ b/event_broker_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" diff --git a/flusher.go b/flusher.go index 2a1f99d..e12744f 100644 --- a/flusher.go +++ b/flusher.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "fmt" diff --git a/flusher_test.go b/flusher_test.go index f7b37ce..9caa46b 100644 --- a/flusher_test.go +++ b/flusher_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" @@ -51,7 +51,7 @@ type benchmarkIsDirtyEntity struct { CreatedAt time.Time `orm:"time=true;index=index_created_at"` LastActiveAt time.Time `orm:"time=true;index=index_last_active_at"` Guild *flushEntity `` - GuildRank string `orm:"enum=beeorm.TestSet"` + GuildRank string `orm:"enum=trixorm.TestSet"` Lang string `orm:"length=2"` CountryCode string `orm:"length=8"` Level uint8 `orm:"index=index_level"` @@ -331,10 +331,10 @@ type flushEntity struct { ReferenceManyRequired []*flushEntityReference `orm:"required"` StringSlice []string StringSliceNotNull []string `orm:"required"` - SetNullable []string `orm:"set=beeorm.TestSet"` - SetNotNull []string `orm:"set=beeorm.TestSet;required"` - EnumNullable string `orm:"enum=beeorm.TestEnum"` - EnumNotNull string `orm:"enum=beeorm.TestEnum;required"` + SetNullable []string `orm:"set=trixorm.TestSet"` + SetNotNull []string `orm:"set=trixorm.TestSet;required"` + EnumNullable string `orm:"enum=trixorm.TestEnum"` + EnumNotNull string `orm:"enum=trixorm.TestEnum;required"` Ignored []string `orm:"ignore"` Blob []uint8 Bool bool @@ -400,8 +400,8 @@ func testFlush(t *testing.T, local bool, redis bool) { var reference *flushEntityReference registry := &Registry{} registry.RegisterRedisStream("entity_changed", "default", []string{"test-group-1"}) - registry.RegisterEnumStruct("beeorm.TestEnum", TestEnum) - registry.RegisterEnumStruct("beeorm.TestSet", TestSet) + registry.RegisterEnumStruct("trixorm.TestEnum", TestEnum) + registry.RegisterEnumStruct("trixorm.TestSet", TestSet) engine, def := prepareTables(t, registry, 5, "", "2.0", entity, reference) defer def() @@ -524,7 +524,7 @@ func testFlush(t *testing.T, local bool, redis bool) { assert.Nil(t, entity.FlushStructPtr) entity.ReferenceOne.Name = "John 2" - assert.PanicsWithError(t, fmt.Sprintf("entity is not loaded and can't be updated: beeorm.flushEntityReference [%d]", refOneID), func() { + assert.PanicsWithError(t, fmt.Sprintf("entity is not loaded and can't be updated: trixorm.flushEntityReference [%d]", refOneID), func() { engine.Flush(entity.ReferenceOne) }) @@ -1113,8 +1113,8 @@ func BenchmarkFlusherUpdateNoCache(b *testing.B) { func BenchmarkIsDirty(b *testing.B) { var entity *benchmarkIsDirtyEntity registry := &Registry{} - registry.RegisterEnum("beeorm.TestEnum", []string{"a", "b", "c"}) - registry.RegisterEnum("beeorm.TestSet", []string{"a", "b", "c"}) + registry.RegisterEnum("trixorm.TestEnum", []string{"a", "b", "c"}) + registry.RegisterEnum("trixorm.TestSet", []string{"a", "b", "c"}) registry.RegisterRedisStream("entity_changed", "default", []string{"test-group-1"}) engine, def := prepareTables(nil, registry, 5, "", "2.0", entity, &flushEntity{}, &flushEntityReference{}) @@ -1372,7 +1372,7 @@ func benchmarkFlusher(b *testing.B, useLocalCache, useRedisCache bool) { var entity *flushEntityBenchmark registry := &Registry{} registry.RegisterRedisStream("entity_changed", "default", []string{"test-group-1"}) - registry.RegisterEnum("beeorm.TestEnum", []string{"a", "b", "c"}) + registry.RegisterEnum("trixorm.TestEnum", []string{"a", "b", "c"}) engine, def := prepareTables(nil, registry, 5, "", "2.0", entity) defer def() diff --git a/global_test.go b/global_test.go index f2f5c99..e912a32 100644 --- a/global_test.go +++ b/global_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" @@ -23,13 +23,8 @@ func (h *testLogHandler) clear() { } func prepareTables(t *testing.T, registry *Registry, mySQLVersion int, redisNamespace, redisSearchVersion string, entities ...Entity) (engine *Engine, def func()) { - if mySQLVersion == 5 { - registry.RegisterMySQLPool("root:root@tcp(localhost:3311)/test?limit_connections=10") - registry.RegisterMySQLPool("root:root@tcp(localhost:3311)/test_log", "log") - } else { - registry.RegisterMySQLPool("root:root@tcp(localhost:3312)/test") - registry.RegisterMySQLPool("root:root@tcp(localhost:3312)/test_log", "log") - } + registry.RegisterMySQLPool("root:root@tcp(localhost:3312)/test?limit_connections=10") + registry.RegisterMySQLPool("root:root@tcp(localhost:3312)/test_log", "log") if redisSearchVersion == "2.0" { registry.RegisterRedis("localhost:6382", redisNamespace, 15) registry.RegisterRedis("localhost:6382", redisNamespace, 14, "default_queue") diff --git a/load_by_id.go b/load_by_id.go index fcbfa14..cc5bc59 100644 --- a/load_by_id.go +++ b/load_by_id.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "fmt" diff --git a/load_by_id_test.go b/load_by_id_test.go index 009256e..e2245f6 100644 --- a/load_by_id_test.go +++ b/load_by_id_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "testing" @@ -252,7 +252,7 @@ func testLoadByID(t *testing.T, local, redis bool) { engine, def = prepareTables(t, &Registry{}, 5, "", "2.0") defer def() entity = &loadByIDEntity{} - assert.PanicsWithError(t, "entity 'beeorm.loadByIDEntity' is not registered", func() { + assert.PanicsWithError(t, "entity 'trixorm.loadByIDEntity' is not registered", func() { engine.LoadByID(1, entity) }) } @@ -265,7 +265,7 @@ func BenchmarkLoadByIDdLocalCache(b *testing.B) { func benchmarkLoadByIDLocalCache(b *testing.B, local, redis bool) { entity := &loadByIDBenchmarkEntity{} registry := &Registry{} - registry.RegisterEnumStruct("beeorm.TestEnum", TestEnum) + registry.RegisterEnumStruct("trixorm.TestEnum", TestEnum) registry.RegisterLocalCache(10000) engine, def := prepareTables(nil, registry, 5, "", "2.0", entity) defer def() diff --git a/load_by_ids.go b/load_by_ids.go index c530d95..115a373 100644 --- a/load_by_ids.go +++ b/load_by_ids.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "fmt" diff --git a/load_by_ids_test.go b/load_by_ids_test.go index 4c282a0..9b78e98 100644 --- a/load_by_ids_test.go +++ b/load_by_ids_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "fmt" @@ -275,7 +275,7 @@ func testLoadByIds(t *testing.T, local, redis bool) { engine, def = prepareTables(t, &Registry{}, 5, "", "2.0") defer def() - assert.PanicsWithError(t, "entity 'beeorm.loadByIdsEntity' is not registered", func() { + assert.PanicsWithError(t, "entity 'trixorm.loadByIdsEntity' is not registered", func() { engine.LoadByIDs([]uint64{1}, &rows) }) } @@ -289,7 +289,7 @@ func benchmarkLoadByIDsLocalCache(b *testing.B) { entity := &schemaEntity{} ref := &schemaEntityRef{} registry := &Registry{} - registry.RegisterEnumStruct("beeorm.TestEnum", TestEnum) + registry.RegisterEnumStruct("trixorm.TestEnum", TestEnum) registry.RegisterLocalCache(10000) engine, def := prepareTables(nil, registry, 5, "", "2.0", entity, ref) defer def() diff --git a/local_cache.go b/local_cache.go index 7a28ac8..7791f97 100644 --- a/local_cache.go +++ b/local_cache.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "fmt" diff --git a/local_cache_test.go b/local_cache_test.go index e99c086..a496659 100644 --- a/local_cache_test.go +++ b/local_cache_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "io/ioutil" diff --git a/locker.go b/locker.go index 59ee293..945db79 100644 --- a/locker.go +++ b/locker.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" diff --git a/locker_test.go b/locker_test.go index 5e4a47b..f9c16cb 100644 --- a/locker_test.go +++ b/locker_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "testing" diff --git a/log_consumer_test.go b/log_consumer_test.go index ad2472e..6835d0a 100644 --- a/log_consumer_test.go +++ b/log_consumer_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" diff --git a/orm.go b/orm.go index 2b8aa4b..9d07740 100644 --- a/orm.go +++ b/orm.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "database/sql" diff --git a/orm_test.go b/orm_test.go index 0f4b2af..6060306 100644 --- a/orm_test.go +++ b/orm_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "testing" diff --git a/pager.go b/pager.go index 3624b24..214da4b 100644 --- a/pager.go +++ b/pager.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm type Pager struct { CurrentPage int diff --git a/pager_test.go b/pager_test.go index cf7e1ea..b2ae992 100644 --- a/pager_test.go +++ b/pager_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "testing" diff --git a/query_logger.go b/query_logger.go index 3e7ac42..f96de5c 100644 --- a/query_logger.go +++ b/query_logger.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "fmt" @@ -14,7 +14,7 @@ type QueryLoggerSource int const sourceMySQL = "mysql" const sourceRedis = "redis" const sourceLocalCache = "local_cache" -const beeORMLogo = "\u001B[1m\x1b[38;2;0;0;0;48;2;255;255;255mBee\u001B[38;2;254;147;51mORM \u001B[0m\x1b[0m\u001B[0m" +const trixormLogo = "\033[1m\033[38;2;72;179;112mt\033[38;2;44;165;173mr\033[38;2;59;103;176mi\033[38;2;201;72;120mx\033[38;2;245;166;35mo\033[38;2;247;200;48mr\033[38;2;72;179;112mm\033[0m" const mysqlLogo = "\x1b[38;2;2;117;143;48;2;255;255;255mMy\u001B[38;2;242;145;17mSQL \u001B[0m\x1b[0m\u001B[0m" const redisLogo = "\u001B[1m\x1b[38;2;191;56;42;48;2;255;255;255mredis \u001B[0m\x1b[0m\u001B[0m" const localCacheLogo = "\u001B[1m\x1b[38;2;254;147;51;48;2;255;255;255mlocal \u001B[0m\x1b[0m\u001B[0m" @@ -29,7 +29,7 @@ type defaultLogLogger struct { } func (d *defaultLogLogger) Handle(fields map[string]interface{}) { - row := beeORMLogo + row := trixormLogo switch fields["source"] { case "mysql": row += mysqlLogo diff --git a/redis_cache.go b/redis_cache.go index eab7f41..60bd2e7 100644 --- a/redis_cache.go +++ b/redis_cache.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" diff --git a/redis_cache_test.go b/redis_cache_test.go index 2b8adab..5c61f35 100644 --- a/redis_cache_test.go +++ b/redis_cache_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" diff --git a/redis_flusher.go b/redis_flusher.go index 3c37f26..9eea805 100644 --- a/redis_flusher.go +++ b/redis_flusher.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm const ( commandDelete = iota diff --git a/redis_flusher_test.go b/redis_flusher_test.go index 6e36216..1586bec 100644 --- a/redis_flusher_test.go +++ b/redis_flusher_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "testing" diff --git a/redis_pipeline.go b/redis_pipeline.go index c53e229..caaa7f3 100644 --- a/redis_pipeline.go +++ b/redis_pipeline.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" diff --git a/redis_pipeline_test.go b/redis_pipeline_test.go index 99d312a..555b91c 100644 --- a/redis_pipeline_test.go +++ b/redis_pipeline_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "testing" diff --git a/redis_search.go b/redis_search.go index ec9998c..0bb1c4b 100644 --- a/redis_search.go +++ b/redis_search.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" diff --git a/redis_search_indexer.go b/redis_search_indexer.go index e8bf4c1..2433d1a 100644 --- a/redis_search_indexer.go +++ b/redis_search_indexer.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "strconv" diff --git a/redis_search_test.go b/redis_search_test.go index 435be9a..1484f7d 100644 --- a/redis_search_test.go +++ b/redis_search_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "context" diff --git a/registry.go b/registry.go index 84016fb..09a88e7 100644 --- a/registry.go +++ b/registry.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "database/sql" diff --git a/request_cache_test.go b/request_cache_test.go index 1aa658a..0c50ba8 100644 --- a/request_cache_test.go +++ b/request_cache_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "testing" diff --git a/schema.go b/schema.go index 1865ba4..f3d2acf 100644 --- a/schema.go +++ b/schema.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "database/sql" @@ -714,7 +714,7 @@ func checkColumn(engine *Engine, schema *tableSchema, field *reflect.StructField definition, addNotNullIfNotSet, addDefaultNullIfNullable, defaultValue = handleTime(attributes, true) case "[]uint8": definition, addDefaultNullIfNullable = handleBlob(attributes) - case "*beeorm.CachedQuery": + case "*trixorm.CachedQuery": return nil, nil default: kind := field.Type.Kind().String() diff --git a/schema_test.go b/schema_test.go index 1289869..98937b8 100644 --- a/schema_test.go +++ b/schema_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "testing" @@ -98,8 +98,8 @@ type schemaEntity struct { RefOne *schemaEntityRef RefMany []*schemaEntityRef Decimal float32 `orm:"decimal=10,2"` - Enum string `orm:"enum=beeorm.TestEnum;required"` - Set []string `orm:"set=beeorm.TestEnum;required"` + Enum string `orm:"enum=trixorm.TestEnum;required"` + Set []string `orm:"set=trixorm.TestEnum;required"` FakeDelete bool IndexAll *CachedQuery `query:""` } @@ -116,7 +116,7 @@ func testSchema(t *testing.T, version int) { entity := &schemaEntity{} ref := &schemaEntityRef{} registry := &Registry{} - registry.RegisterEnumStruct("beeorm.TestEnum", TestEnum, "b") + registry.RegisterEnumStruct("trixorm.TestEnum", TestEnum, "b") engine, def := prepareTables(t, registry, version, "", "2.0", entity, ref) defer def() @@ -228,7 +228,7 @@ func testSchema(t *testing.T, version int) { engine.GetMysql().Exec(alters[1].SQL) schema := engine.GetRegistry().GetTableSchemaForEntity(entity) - assert.Equal(t, "beeorm.schemaEntity", schema.GetType().String()) + assert.Equal(t, "trixorm.schemaEntity", schema.GetType().String()) references := schema.GetReferences() assert.Len(t, references, 2) columns := schema.GetColumns() @@ -272,20 +272,20 @@ func testSchema(t *testing.T, version int) { registry.RegisterMySQLPool(pool) registry.RegisterEntity(&schemaInvalidIndexEntity{}) _, _, err := registry.Validate() - assert.EqualError(t, err, "invalid entity struct 'beeorm.schemaInvalidIndexEntity': invalid index position 'invalid' in index 'TestIndex'") + assert.EqualError(t, err, "invalid entity struct 'trixorm.schemaInvalidIndexEntity': invalid index position 'invalid' in index 'TestIndex'") registry = &Registry{} registry.RegisterMySQLPool(pool) registry.RegisterEntity(&schemaInvalidMaxStringEntity{}) _, _, err = registry.Validate() - assert.EqualError(t, err, "invalid entity struct 'beeorm.schemaInvalidMaxStringEntity': invalid max string: invalid") + assert.EqualError(t, err, "invalid entity struct 'trixorm.schemaInvalidMaxStringEntity': invalid max string: invalid") registry = &Registry{} registry.RegisterMySQLPool(pool) registry.RegisterLocalCache(1000) registry.RegisterEntity(&schemaEntity{}) _, _, err = registry.Validate() - assert.EqualError(t, err, "invalid entity struct 'beeorm.schemaEntity': unregistered enum beeorm.TestEnum") + assert.EqualError(t, err, "invalid entity struct 'trixorm.schemaEntity': unregistered enum trixorm.TestEnum") engine, _ = prepareTables(t, &Registry{}, 5, "", "2.0", &schemaToDropEntity{}) schema = engine.GetRegistry().GetTableSchemaForEntity(&schemaToDropEntity{}) @@ -356,7 +356,7 @@ func testSchema(t *testing.T, version int) { } registry.RegisterEntity(&invalidSchema6{}) _, _, err = registry.Validate() - assert.EqualError(t, err, "missing unique index for cached query 'IndexName' in beeorm.invalidSchema6") + assert.EqualError(t, err, "missing unique index for cached query 'IndexName' in trixorm.invalidSchema6") registry = &Registry{} registry.RegisterMySQLPool(pool) @@ -368,7 +368,7 @@ func testSchema(t *testing.T, version int) { } registry.RegisterEntity(&invalidSchema7{}) _, _, err = registry.Validate() - assert.EqualError(t, err, "missing index for cached query 'IndexName' in beeorm.invalidSchema7") + assert.EqualError(t, err, "missing index for cached query 'IndexName' in trixorm.invalidSchema7") registry = &Registry{} registry.RegisterMySQLPool(pool) @@ -381,7 +381,7 @@ func testSchema(t *testing.T, version int) { } registry.RegisterEntity(&invalidSchema8{}) _, _, err = registry.Validate() - assert.EqualError(t, err, "missing unique index for cached query 'IndexName' in beeorm.invalidSchema8") + assert.EqualError(t, err, "missing unique index for cached query 'IndexName' in trixorm.invalidSchema8") registry = &Registry{} registry.RegisterMySQLPool(pool) @@ -394,5 +394,5 @@ func testSchema(t *testing.T, version int) { } registry.RegisterEntity(&invalidSchema9{}) _, _, err = registry.Validate() - assert.EqualError(t, err, "missing index for cached query 'IndexName' in beeorm.invalidSchema9") + assert.EqualError(t, err, "missing index for cached query 'IndexName' in trixorm.invalidSchema9") } diff --git a/search.go b/search.go index e9deb2f..0d42d74 100644 --- a/search.go +++ b/search.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "database/sql" @@ -272,7 +272,7 @@ func getEntityTypeForSlice(registry *validatedRegistry, sliceType reflect.Type, if name[0] == 91 { name = name[3:] } else if checkIsSlice { - panic(fmt.Errorf("interface %s is no slice of beeorm.Entity", sliceType.String())) + panic(fmt.Errorf("interface %s is no slice of trixorm.Entity", sliceType.String())) } e, has := registry.entities[name] return e, has, name diff --git a/search_test.go b/search_test.go index d990b66..9a20a3e 100644 --- a/search_test.go +++ b/search_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "fmt" @@ -81,7 +81,7 @@ func TestSearch(t *testing.T) { assert.True(t, entity.ReferenceMany[2].IsLoaded()) engine, _ = prepareTables(t, &Registry{}, 5, "", "2.0") - assert.PanicsWithError(t, "entity 'beeorm.searchEntity' is not registered", func() { + assert.PanicsWithError(t, "entity 'trixorm.searchEntity' is not registered", func() { engine.Search(NewWhere("ID > 0"), nil, &rows) }) } diff --git a/serializer.go b/serializer.go index f593b95..6e04d6a 100644 --- a/serializer.go +++ b/serializer.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "bytes" diff --git a/table_schema.go b/table_schema.go index f4e976a..09f5663 100644 --- a/table_schema.go +++ b/table_schema.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "crypto/sha256" @@ -726,7 +726,7 @@ func (tableSchema *tableSchema) buildTableFields(t reflect.Type, registry *Regis case "*float32", "*float64": tableSchema.buildFloatPointerField(attributes) - case "*beeorm.CachedQuery": + case "*trixorm.CachedQuery": continue case "*time.Time": tableSchema.buildTimePointerField(attributes) @@ -1272,7 +1272,7 @@ func extractTag(registry *Registry, field reflect.StructField) map[string]map[st return map[string]map[string]string{field.Name: attributes} } else if field.Type.Kind().String() == "struct" { t := field.Type.String() - if t != "beeorm.ORM" && t != "time.Time" { + if t != "trixorm.ORM" && t != "time.Time" { prefix := "" if !field.Anonymous { prefix = field.Name diff --git a/tools/redis_search_statistic_test.go b/tools/redis_search_statistic_test.go index db9c63d..8641ae3 100644 --- a/tools/redis_search_statistic_test.go +++ b/tools/redis_search_statistic_test.go @@ -3,16 +3,16 @@ package tools import ( "testing" + "github.com/coretrix/trixorm" jsoniter "github.com/json-iterator/go" - "github.com/latolukasz/beeorm" "github.com/stretchr/testify/assert" ) func TestRedisSearchStatistics(t *testing.T) { - registry := &beeorm.Registry{} + registry := &trixorm.Registry{} registry.RegisterRedis("localhost:6382", "", 0) - registry.RegisterRedisSearchIndex(&beeorm.RedisSearchIndex{Name: "test", RedisPool: "default", Prefixes: []string{"test:"}}) + registry.RegisterRedisSearchIndex(&trixorm.RedisSearchIndex{Name: "test", RedisPool: "default", Prefixes: []string{"test:"}}) validatedRegistry, def, err := registry.Validate() assert.NoError(t, err) defer def() @@ -23,8 +23,8 @@ func TestRedisSearchStatistics(t *testing.T) { } stats := GetRedisSearchStatistics(engine) assert.Len(t, stats, 1) - assert.Equal(t, "test", stats[0].Index.Name) - assert.Equal(t, "test", stats[0].Info.Name) + assert.Equal(t, "test", stats[0].Index) + assert.Equal(t, "test", stats[0].Info) asJSON, err := jsoniter.ConfigFastest.Marshal(stats) assert.NoError(t, err) assert.NotEmpty(t, asJSON) diff --git a/tools/redis_search_statistics.go b/tools/redis_search_statistics.go index 7f342d2..6a0d147 100644 --- a/tools/redis_search_statistics.go +++ b/tools/redis_search_statistics.go @@ -1,7 +1,7 @@ package tools import ( - orm "github.com/latolukasz/beeorm" + orm "github.com/coretrix/trixorm" ) type RedisSearchStatistics struct { diff --git a/tools/redis_statistic_test.go b/tools/redis_statistic_test.go index 6d3ebca..ad48de1 100644 --- a/tools/redis_statistic_test.go +++ b/tools/redis_statistic_test.go @@ -3,12 +3,12 @@ package tools import ( "testing" - "github.com/latolukasz/beeorm" + "github.com/coretrix/trixorm" "github.com/stretchr/testify/assert" ) func TestRedisStatistics(t *testing.T) { - registry := &beeorm.Registry{} + registry := &trixorm.Registry{} registry.RegisterRedis("localhost:6382", "", 15) registry.RegisterRedis("localhost:6382", "", 14, "another") validatedRegistry, def, err := registry.Validate() diff --git a/tools/redis_statistics.go b/tools/redis_statistics.go index 88b6ada..f4da834 100644 --- a/tools/redis_statistics.go +++ b/tools/redis_statistics.go @@ -4,7 +4,7 @@ import ( "sort" "strings" - orm "github.com/latolukasz/beeorm" + orm "github.com/coretrix/trixorm" ) type RedisStatistics struct { diff --git a/tools/redis_streams_statistics.go b/tools/redis_streams_statistics.go index 1e30441..78d6c9b 100644 --- a/tools/redis_streams_statistics.go +++ b/tools/redis_streams_statistics.go @@ -6,7 +6,7 @@ import ( "strings" "time" - orm "github.com/latolukasz/beeorm" + orm "github.com/coretrix/trixorm" ) type RedisStreamStatistics struct { diff --git a/tools/redis_streams_statistics_test.go b/tools/redis_streams_statistics_test.go index ee8af97..2f0b9f0 100644 --- a/tools/redis_streams_statistics_test.go +++ b/tools/redis_streams_statistics_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - orm "github.com/latolukasz/beeorm" + orm "github.com/coretrix/trixorm" "github.com/stretchr/testify/assert" ) diff --git a/uuid.go b/uuid.go index 45a220a..79e6620 100644 --- a/uuid.go +++ b/uuid.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "sync/atomic" diff --git a/uuid_test.go b/uuid_test.go index 5fe9f99..741cc2a 100644 --- a/uuid_test.go +++ b/uuid_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "testing" diff --git a/validated_registry.go b/validated_registry.go index d034d73..dca6ed2 100644 --- a/validated_registry.go +++ b/validated_registry.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "fmt" diff --git a/validated_registry_test.go b/validated_registry_test.go index 0462006..c9bb7cb 100644 --- a/validated_registry_test.go +++ b/validated_registry_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "reflect" @@ -37,7 +37,7 @@ func TestValidatedRegistry(t *testing.T) { assert.NotNil(t, source) entities := validated.GetEntities() assert.Len(t, entities, 1) - assert.Equal(t, reflect.TypeOf(validatedRegistryEntity{}), entities["beeorm.validatedRegistryEntity"]) + assert.Equal(t, reflect.TypeOf(validatedRegistryEntity{}), entities["trixorm.validatedRegistryEntity"]) assert.Nil(t, validated.GetTableSchema("invalid")) enum := validated.GetEnum("enum_map") @@ -74,7 +74,7 @@ func TestValidatedRegistry(t *testing.T) { assert.Equal(t, "another", localCachePools["another"].GetCode()) assert.Equal(t, 50, localCachePools["another"].GetLimit()) - assert.PanicsWithError(t, "entity 'beeorm.validatedRegistryNotRegisteredEntity' is not registered", func() { + assert.PanicsWithError(t, "entity 'trixorm.validatedRegistryNotRegisteredEntity' is not registered", func() { validated.GetTableSchemaForEntity(&validatedRegistryNotRegisteredEntity{}) }) diff --git a/where.go b/where.go index 5562c22..ba1ddfe 100644 --- a/where.go +++ b/where.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "reflect" diff --git a/where_test.go b/where_test.go index bd13870..1675ea1 100644 --- a/where_test.go +++ b/where_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "testing" diff --git a/yaml_loader.go b/yaml_loader.go index 781164e..654dcd3 100644 --- a/yaml_loader.go +++ b/yaml_loader.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "fmt" diff --git a/yaml_loader_test.go b/yaml_loader_test.go index ff4dc3b..c3c0325 100644 --- a/yaml_loader_test.go +++ b/yaml_loader_test.go @@ -1,4 +1,4 @@ -package beeorm +package trixorm import ( "io/ioutil"