Giter Site home page Giter Site logo

Primary key about bun HOT 5 CLOSED

uptrace avatar uptrace commented on July 18, 2024
Primary key

from bun.

Comments (5)

vmihailenco avatar vmihailenco commented on July 18, 2024 1

Should be fixed by 5176653

Looking at the code it should warn about the usage of pk as a column name as it is also an option

It is unrelated to this issue, but we may indeed improve the check in case of bun:"pk,pk.

from bun.

isgj avatar isgj commented on July 18, 2024

Maybe by adding another pk option

type User {
    ID int64 `bun:"pk,pk,autoincrement"`
}

The first pk to tell that field ID is backed by pk column in db, the second to tell it's a primary key. Looking at the code it should warn about the usage of pk as a column name as it is also an option

if tag.Name != sqlName && isKnownFieldOption(tag.Name) {
	internal.Warn.Printf(
		"%s.%s tag name %q is also an option name; is it a mistake?",
		t.TypeName, f.Name, tag.Name,
	)
}

from bun.

sloan-dog avatar sloan-dog commented on July 18, 2024

Is the bun:"option1,option2,option3" format documented anywhere? I could not find a comprehensive list of struct tags and their components in current bun docs. Know it is a new -ish project, but derived from another. It was not apparent to me how to canonically indicate a field is a primary key in bun.

from bun.

vmihailenco avatar vmihailenco commented on July 18, 2024

Looks like that info was lost during migration :( I will restore it, but meanwhile you can check https://pg.uptrace.dev/models/#struct-tags

from bun.

vmihailenco avatar vmihailenco commented on July 18, 2024

Docs were updated - https://bun.uptrace.dev/guide/models.html#struct-tags

from bun.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.