https://lakefs.io/ logo
Docs
Join the conversationJoin Slack
Channels
announcements
blockers_for_windward
career-opportunities
celebrations
cuddle-corner
data-discussion
data-events
dev
events
general
help
iceberg-integration
lakefs-for-beginners
lakefs-hubspot-cloud-registration-email-automation
lakefs-releases
lakefs-suggestions
lakefs-twitter
linen-dev
memes-and-banter
new-channel
new-channel
say-hello
stackoverflow
test
Powered by Linen
stackoverflow
  • r

    rss

    01/27/2023, 2:47 PM
    GORM thread-safe connection I have simple code on golang which is executed while receive request and update a value on database. res := db.Where(ExampleStructforDB{Id: Id}).FirstOrCreate(&ls) if res.Error != nil { log.Error(res.Error) return res.Error } ls.count += 1 err = Db.Save(&ls).Error if err != nil { log.Error(err) return err } Sometimes I see that there is a race condition.Time-to-time some of the requests gets same value from database for updating.But in fact that, every...
  • r

    rss

    01/27/2023, 2:47 PM
    GORM and PostgreSQL: search_path is used only when doing the first request I'm currently working on an api gateway that forwards requests to an grpc client. The routes use a middleware. Within that middleware the Validate function from the dialed grpc client is used. The function is in the last code snippet at the end. The gateway is based on a gin router, which, as far as I understand handles each request in a separat go routine. I can send as many requests simultaneously to either to endpoint /protected/1 or to endpoint /protected/2 and they get handled...
  • r

    rss

    01/27/2023, 2:47 PM
    GORM v2 Many to Many does not create new record in join table Two structs Thread & Interest have a many to many relationship with each other. According to the documentation this is how both structs looks like: type Thread struct { ID uuid.UUID
    gorm:"primaryKey" json:"threadId"
    Title string
    gorm:"not null" json:"title"
    Body string
    gorm:"not null" json:"body"
    CreatedAt time.Time UpdatedAt time.Time // Foreign keys UserID uuid.UUID
    json:"userId"
    // Has many association Comments []Comment...
  • r

    rss

    01/27/2023, 2:47 PM
    Is it possible to change the database type of an enum in gorm (using postgres)? I wonder if its possible to change the datatype of an enum in gorm when it has the same underlying type? So say this is my current model type A type typeA int32 const ( field1 typeA = 0 field2 typeA = 1 field3 typeA = 2 ) type typeB int32 const ( field1 typeB = 0 field2 typeB = 1 field3 typeB = 2 ) And I have my gorm model like this type MyModel struct { gorm.Model SomeField typeA } I wonder if I...
  • r

    rss

    01/27/2023, 2:47 PM
    Rewrite query with union in subquery by using gorm I am trying to write sql query by using gorm. Here the query SELECT * FROM ( SELECT unnest(tags) as tag_name FROM models union all SELECT unnest(system_tags) from models left join projects on projects.id = models.project_id WHERE (projects.is_public = true )) as tD WHERE LOWER( tD.tag_name ) LIKE '%12%' ORDER BY tag_name I tried to create subquery. But cant figure out how to add union. As I understand select does not work this way. Is using Raw() my only option? selectStr...
  • r

    rss

    01/27/2023, 2:47 PM
    Insert into multiple tables on one transaction using GORM I'm trying to store information in 3 tables in a single transaction using GORM. I need to create just one row on Table1 and Table2 and multiple records on Table3 type Table1 struct { Id uuid.UUID
    gorm:"type:uuid;primary_key;default:uuid_generate_v4()"
    } type Table2 struct { Id uuid.UUID
    gorm:"type:uuid;primary_key;default:uuid_generate_v4()"
    Table2ID uuid.UUID
    gorm:"type:uuid;default:uuid_generate_v4()"
    Table2 Table2 } type Table3 struct...
  • r

    rss

    01/27/2023, 2:47 PM
    Go Gin Gorm how can you combine both has many and belongs to? I have two structs Thread and User. User currently has a 'has many' relationship with Thread. The two structs are: type Thread struct { ID uuid.UUID
    gorm:"primaryKey" json:"threadId"
    Title string
    gorm:"not null" json:"title"
    Body string
    gorm:"not null" json:"body"
    CreatedAt time.Time
    json:"createdAt"
    UpdatedAt time.Time
    json:"updatedAt"
    // Foreign keys UserID uuid.UUID
    json:"userId"
    // Has many association Comments...
  • r

    rss

    01/27/2023, 2:47 PM
    How do I get Failed results when using GORM batch creation? I am trying to create records using the Gorm CreateInBatches method. I do not want to fail the complete batch operation if there is any conflict so I am using the gorm clause to ignore conflicts, but I am unable to get failed records with this approach. Is there a way to get the failed records when using batching with ignore clause in Gorm? code: gormDbClient.Clauses(clause.OnConflict{DoNothing: true}).CreateInBatches(users, 500)
  • r

    rss

    01/27/2023, 2:47 PM
    Gorm delete with clauses sqlmock test I have a Gorm delete with the returning result: expirationDate := time.Now().UTC().Add(-(48 * time.hour)) var deletedUsers Users res := gormDB.WithContext(ctx). Table("my_users"). Clauses(clause.Returning{Columns: []clause.Column{{Name: "email"}}}). Where("created_at < ?", expirationDate). Delete(&deletedUsers) Now the test with clauses always fails. e.g. : sqlMock.ExpectExec(
    DELETE
    ) .WithArgs(expirationDate) .WillReturnResult(sqlmock.NewResult(1, 1)) Receiving...
  • r

    rss

    01/27/2023, 2:47 PM
    How to view the SQL query being run while using go gorm? [duplicate] I am working on crud api using go-gorm. I want to log the exact query which is being executed on the database when I run the code(like in hibernate). For example when db.Create(&user) is executed . It should log INSERT INTO
    users
    (
    name
    ,
    age
    ,
    created_at
    ) VALUES ("jinzhu", 18, "2020-07-04 11:05:21.775") What configuration should I do to achieve this ?
  • r

    rss

    01/27/2023, 2:47 PM
    How to create association only if it doesn't exist? (GORM) I am looping through an array of strings to create an document with that property ONLY if it doesn't exist: (dbi: my GORM database instance) var postTags []models.Tag for _, tagSlug := range tagsArray { tag := models.Tag{ Slug: tagSlug, } err = dbi.Where("slug = ?", tagSlug).FirstOrCreate(&tag).Error if err != nil { return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ "error": "Internal Server Error", }) }...
  • r

    rss

    01/27/2023, 2:47 PM
    Problem writing a unit test using gorm and sql-mock this is my funckion using package testing, gorm and sql-mock: func Test_Create(t *testing.T) { db, mock, err := sqlmock.New() if err != nil { t.Errorf("Failed to open mock sql db, got error: %v", err) } if db == nil { t.Error("db is null") } if mock == nil { t.Error("mock is null") } defer db.Close() pDb, err := gorm.Open(postgres.New(postgres.Config{ PreferSimpleProtocol: false, DriverName: "postgres",...
  • r

    rss

    01/27/2023, 2:47 PM
    gorm queries apparently running twice when using in a fiber app hello i am studying gofiber, i am using GORM and github.com/morkid/paginate, i got something odd , i think, the query to fetch my data is running twice, is that correct? this is the code func GetAllPost(c *fiber.Ctx) error { var posts []models.Post model := initializers.DB.Find(&posts) return c.JSON(fiber.Map{ "data": pg.With(model).Request(c.Request()).Response(&[]models.Post{}), }) } this is the response { "data": { "items": [ {...
  • r

    rss

    01/27/2023, 2:47 PM
    how to remove some elements from the response in golang I am studying gofiber, I am using GORM and github.com/morkid/paginate, I want to remove the child element from the response. this is the response { "data": { "items": [ { "ID": 1, "CreatedAt": "2023-01-22T02:33:12.604+08:00", "UpdatedAt": "2023-01-22T02:33:12.604+08:00", "DeletedAt": null, "email": "ilham@mail.com", "username": "", "names": "",...
  • r

    rss

    01/27/2023, 2:47 PM
    Single Table Inheritance in Go using gorm I want to achive Single Table Inheritance in Go using gorm library, but i can't find a way to do it or any documentation related to it. Do anyone have already done that or knows about it? I tried gorm:"discriminator" and gorm:"discriminator:value" but it's not working.
  • r

    rss

    01/27/2023, 2:47 PM
    GORM scanrows vs scan in a raw query I found out I got different results using ScanRows or Scan. if I use: err=models.DB.ScanRows(nodes, &node) I get empty values in some fields. If I replace the structure node for all the attributes: err = nodes.Scan(&node.NodoId, &node.NodoIdPadre, &node.TipoNodo, &node.SubFormulaId, &node.FuncionId, &node.TipoTerminoId, &node.TerminoId,&node.FuncionDesc, &node.CodFormula, &node.TipoTerminoDesc, &node.DescTipoNodo, &node.OperadorId, &node.Operador ) It does not have any NULL...
  • r

    rss

    01/27/2023, 2:47 PM
    Using Gorm model with custom sequence I have a seq 'user_tfa_info_seq' which I want to use in 'user_tfa_info' table in Gorm Model. I used the following structure, but it does not work. type UserTfaInfo struct{ ID uint
    gorm:"primary_key;type:bigint(20) not null" sql:"nextval('user_tfa_info_seq')"
    }
  • r

    rss

    01/27/2023, 2:47 PM
    How to create a new instance of a struct that is read from file I know this may seem like bad design (and I wish I didn't need to do this), but I need to read a struct that is generated automatically at run time and create a new instance of it. The struct that I create I only need limited metadata of so that it can be passed to the Gorm Gen FieldRelateModel method (from here) where 'relModel' is the new instance I am hoping...
  • r

    rss

    01/27/2023, 2:47 PM
    Concurrent MySQL writing with GORM leads to an error I have implemented a complex csv import script in Golang. I use a Workerpool implementation for it. Inside that workerpool, workers run through 1000s of small csv files, categorizing, tagging and branding the products. And they all write to the same database table. So far so good. The problem i'm facing is, that if i chose more than 2 workers, the process crashes with the following message randomly

    https://i.stack.imgur.com/0yQpX.jpg▾

    The workflow is...
  • r

    rss

    01/27/2023, 2:47 PM
    Golang GORM DB mock I have to mock test a service.to create new service i need to pass gorm.DB{} but every time i pass it and run the test i get nil pointer error(panic). please help on how to mock gorm.DB{} instance correctly for unit testing. func NewService(db *gorm.DB) Service { return &service{ repo: newReactionRepo(db), } } making the mock call in the test like this :- mockDB = &gorm.DB{} package.NewService(mockDB) getting this error testing.tRunner.func1.2({0x1648e40, 0x21cdd60})...
  • r

    rss

    02/04/2023, 10:17 AM
    How to run lakefs in goland? I downloaded the source code of version 0.68.0 and imported it into goland. I found some functions are missing. E.g. I can't find the definition of function "HandlerFromMuxWithBaseURL" which is invoked at line 94 in pkg/api/serve.go. Can anyone help me?
  • r

    rss

    02/09/2023, 5:27 PM
    lakeFS Docker build fails I am trying to get started with a "local" data processing ecosystem which includes Presto, Spark, Hive. lakeFS and a few other. My docker-compose.yml looks like this: version: "3.5" services: lakefs: image: treeverse/lakefs:latest container_name: lakefs depends_on: - minio-setup ports: - "8000:8000" environment: - LAKEFS_DATABASE_TYPE=local - LAKEFS_BLOCKSTORE_TYPE=s3 - LAKEFS_BLOCKSTORE_S3_FORCE_PATH_STYLE=true -...
  • r

    rss

    02/10/2023, 12:47 PM
    Is there a mechanism in Google PageSpeed Insights where we can receive an alert about the score? [closed] I want to write a program to check Google PageSpeed Score in a daily basis. Is there a mechanism in Google PageSpeed Insights or Google Analytics where we can program a test every day, and receive an alert if the score of the web or mobile page is below a certain score? Thank you
  • r

    rss

    02/10/2023, 12:47 PM
    Calculating single-page visit % in Lookerstudio [closed] I'm trying to create a metric for % single-page visits using Lookerstudio (Datastudio). This would be different from bounce rate which considers non-interaction events in the calucluation. I want a pure percent of sessions that were only 1 page viewed. I can get to Sessions and also single-page sessions by filtering sessions where Page Depth = 1. But how can I divide those two numbers together to create the % calculation? I've tried adding a field with a CASE statement to only return a value...
  • r

    rss

    02/10/2023, 12:47 PM
    Google Analytics 4 register events serverside Currently we are using Google Universal Analytics and registering events serverside using this library (NodeJs). https://github.com/peaksandpies/universal-analytics This is being depreciated for Google Analytics 4. Is there any API that will work with Google Analytics 4 serverside?
  • r

    rss

    02/10/2023, 12:47 PM
    How to secure _gat cookie using javascript or c#? I want to secure my _gcl & _gat cookies of Google Analytics using javascript or c#. Want to secure the cookies with following tags - HttpOnly, **SameSite **& *Secure *

    https://i.stack.imgur.com/71ZAv.png▾

    I have tried below code. But it doesn't work ga('create', 'UA-1XXX-Y', { cookieFlags: 'max-age=7200;secure;samesite=none' });
  • r

    rss

    02/10/2023, 12:47 PM
    Unable to parse Measurement Protocol JSON payload I am trying to send a post payload however I was returned an error, can advise? tracking_id is the id that I am using. url = "https://www.google-analytics.com/debug/mp/collect" payload = { "v": 1, "tid": tracking_id, "cid": 555, "t": "event", "ec": "download", "ea": "file_download", "el": data['file_name'], "ev": 1, "cd5": data['hash'] } response = requests.post(url, data=payload)...
  • r

    rss

    02/10/2023, 12:47 PM
    How do I view the values in Track_URL defined by Google Javascript events This is the following event I am capturing in Google Analytics. How do I view the event_label in Report or Explore options. What is the dimension that I need to select? When I was viewing custom report/explore I simply done see any event category gtag('event', 'Track_URL', { 'event_category': 'URL Tracking', 'event_label': window.location.href });

    Cannot find event_category dimension▾

  • r

    rss

    02/10/2023, 12:47 PM
    How to connect and run Google Big Query to Tableau for my GA4 data? I have connected Google Big Query to Tableau for my GA4 data. However, the data is split across several tables, each corresponding to a single day. How can I consolidate all these tables into a single, comprehensive table?

    https://i.stack.imgur.com/VECl6.png▾

  • r

    rss

    02/10/2023, 12:47 PM
    How to use item-scoped dimensions and event-scoped metrics together? According to the schema changes item-scoped dimensions and event-scoped metrics are incompatible. Before the changes I used the "itemViewEvents" (event-scope metric) and the "itemName" (item-scoped dimension) to get the number of views for a given product. Is it possible to get this data after the changes? I guess we should create a custom metric/dimension for this, but I'm not sure.
Powered by Linen
Title
r

rss

02/10/2023, 12:47 PM
How to use item-scoped dimensions and event-scoped metrics together? According to the schema changes item-scoped dimensions and event-scoped metrics are incompatible. Before the changes I used the "itemViewEvents" (event-scope metric) and the "itemName" (item-scoped dimension) to get the number of views for a given product. Is it possible to get this data after the changes? I guess we should create a custom metric/dimension for this, but I'm not sure.
View count: 3