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

Schema not being parsed in Table Group #20

Closed
mjfii opened this issue Jul 13, 2022 · 2 comments
Closed

Schema not being parsed in Table Group #20

mjfii opened this issue Jul 13, 2022 · 2 comments

Comments

@mjfii
Copy link

mjfii commented Jul 13, 2022

It appears that the new schema functionally does not work within the Table Group, where the schema is required to be explicit in the Table Group definition. Here is some valid dbml:


// this is a test scenario
Project test_scenario_1 {
  Note: '''
  test scenario for schema management
  '''
}

Table test.sales {
  sales_id int [primary key]
  calendar_date date [not null]
  quantity integer [not null]
  sales_amount decimal [not null]
  account_owner_employee_id int [not null]
  sales_rep_employee_id int [not null]
}

Table test.employee as emp {
  employee_id int [primary key]
  employee_name string [not null]
  manager_employee_id int [not null]
  country_code string [null]
  title_id string [null]
}

Table test.country as cnt {
  country_code string [primary key]
  country_name string [unique, not null]
}

Table test.title {
  title_id string [primary key]
  title_name string [not null]
}

Ref sales_refs_employee__account_owner {
  test.sales.account_owner_employee_id > test.employee.employee_id
}

Ref sales_refs_employee__sales_rep {
  test.sales.sales_rep_employee_id > test.employee.employee_id
}

Ref employee_refs_employee__manager {
  test.employee.manager_employee_id > test.employee.employee_id
}

Ref employee_refs_country {
  test.employee.country_code > test.country.country_code
}

Ref employee_refs_title__current {
  test.employee.title_id > test.title.title_id
}

Table test.calendar {
  calendar_date date [not null]
  fiscal_month int [not null]
}

Ref sales_refs_calendar {
  test.sales.calendar_date > test.calendar.calendar_date
}

Tablegroup test_table_group_1 {
  test.sales
  test.employee
  test.country
  test.title
  test.calendar
}

It will yield an error due to pydbml/definitions/table_group.py, I believe.

  File "~git~/venv/lib/python3.8/site-packages/pydbml/parser/parser.py", line 175, in locate_table
  raise TableNotFoundError(f'Table {full_name} not present in the database')
pydbml.exceptions.TableNotFoundError: Table ['test', 'sales'].test not present in the database

If we remove the Table Group, the schema in the below parses normally.

// this is a test scenario
Project test_scenario_1 {
  Note: '''
  test scenario for schema management
  '''
}

Table test.sales {
  sales_id int [primary key]
  calendar_date date [not null]
  quantity integer [not null]
  sales_amount decimal [not null]
  account_owner_employee_id int [not null]
  sales_rep_employee_id int [not null]
}

Table test.employee as emp {
  employee_id int [primary key]
  employee_name string [not null]
  manager_employee_id int [not null]
  country_code string [null]
  title_id string [null]
}

Table test.country as cnt {
  country_code string [primary key]
  country_name string [unique, not null]
}

Table test.title {
  title_id string [primary key]
  title_name string [not null]
}

Ref sales_refs_employee__account_owner {
  test.sales.account_owner_employee_id > test.employee.employee_id
}

Ref sales_refs_employee__sales_rep {
  test.sales.sales_rep_employee_id > test.employee.employee_id
}

Ref employee_refs_employee__manager {
  test.employee.manager_employee_id > test.employee.employee_id
}

Ref employee_refs_country {
  test.employee.country_code > test.country.country_code
}

Ref employee_refs_title__current {
  test.employee.title_id > test.title.title_id
}

Table test.calendar {
  calendar_date date [not null]
  fiscal_month int [not null]
}

Ref sales_refs_calendar {
  test.sales.calendar_date > test.calendar.calendar_date
}
Vanderhoof added a commit that referenced this issue Jul 24, 2022
(#20) Fix schema parsing in TableGroupBlueprint
@Vanderhoof
Copy link
Owner

Thanks for reporting! Fixed in 1.0.2 (I'll try to release it today or next weekend)

@Vanderhoof
Copy link
Owner

(Probably better to keep it open until the actual release)

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

No branches or pull requests

2 participants