Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a default for UUID primary keys #9

Closed
helje5 opened this issue Aug 23, 2022 · 1 comment
Closed

Add a default for UUID primary keys #9

helje5 opened this issue Aug 23, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@helje5
Copy link
Member

helje5 commented Aug 23, 2022

Let's say we have:

CREATE TABLE talent (
  talent_id UUID NOT NULL,
  name      TEXT NOT NULL
);

which generates

struct Talent {
  var id   : UUID
  var name : String
  init(id: UUID, name: String) { ... }
}

it would be nice if the init would be init(id: UUID = UUID(), name: String). As that kinda is the sane thing to do for new records.

@helje5 helje5 added the enhancement New feature or request label Aug 23, 2022
@helje5 helje5 self-assigned this Aug 24, 2022
helje5 added a commit that referenced this issue Aug 24, 2022
If a structure has a UUID primary key, generate a default
UUID for it, like:
```swift
init(id: UUID = UUID()) {}
```

Implements issue #9.
@helje5
Copy link
Member Author

helje5 commented Aug 24, 2022

Implemented.

@helje5 helje5 closed this as completed Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant