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

make dsl more compatible #384

Open
pynixwang opened this issue Mar 7, 2020 · 4 comments
Open

make dsl more compatible #384

pynixwang opened this issue Mar 7, 2020 · 4 comments

Comments

@pynixwang
Copy link

require "granite/adapter/mysql"

class Post < Granite::Base
  connection mysql
  table posts # this strange
  # table :posts also work
  # table "posts" also work

  column id : Int64, primary: true # Primary key, defaults to AUTO INCREMENT
  column name : String? # Nilable field
  column body : String # Not nil field
end
@Blacksmoke16
Copy link
Contributor

Blacksmoke16 commented Mar 7, 2020

What exactly are you proposing here?

@pynixwang
Copy link
Author

table posts # this strange
 # table :posts also work
 # table "posts" also work

make macro args more compatible

@Blacksmoke16
Copy link
Contributor

For anyone wanting to do this, https://github.com/amberframework/granite/blob/master/src/granite/table.cr#L54

Needs to be: @[Granite::Table(name: {{(name.is_a?(StringLiteral) ? name : name.id.stringify) || nil}})]

@pynixwang
Copy link
Author

connection also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants