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

View that joins to self results in 'unknown column' on refresh 'BOTH' #109

Open
mvincent opened this issue Dec 3, 2014 · 0 comments
Open

Comments

@mvincent
Copy link

mvincent commented Dec 3, 2014

I have created a materialized view to be a view of a single table (using a nested set model) that joins onto itself a couple of times.

The resulting view works perfectly. However, upon a call to flexviews.refresh, I receive this message:

ERROR 1054 (42S22) at line 37: Unknown column 'region.parent_id' in 'on clause'

Below is the flexviews API I'm using:

call flexviews.create_mvlog('fst', 'place');

call flexviews.CREATE('fst',
                      'mv_place',
                      'INCREMENTAL'
                      );

select @mvid := last_insert_id();

call flexviews.add_table(@mvid, 'fst','place', 'territory', NULL);
call flexviews.add_table(@mvid, 'fst','place', 'region', 'ON territory.parent_id = region._id');
call flexviews.add_table(@mvid, 'fst','place', 'company', 'ON region.parent_id = company._id');
call flexviews.add_expr(@mvid, 'COLUMN', 'territory._id', '_id');
call flexviews.add_expr(@mvid, 'COLUMN', 'company._id', 'company_id');
call flexviews.add_expr(@mvid, 'COLUMN', 'region._id', 'region_id');
call flexviews.add_expr(@mvid, 'COLUMN', 'territory._id', 'territory_id');
call flexviews.add_expr(@mvid, 'COLUMN', 'territory.lft', 'territory_lft');
call flexviews.add_expr(@mvid, 'COLUMN', 'territory.lft + 1', 'territory_lft_plus_one');
call flexviews.add_expr(@mvid, 'COLUMN', 'territory.rght', 'territory_rght');
call flexviews.add_expr(@mvid, 'COLUMN', 'territory.type', 'territory_type');
call flexviews.add_expr(@mvid, 'KEY', 'territory_lft_plus_one,territory_rght', 'territory_eq_key');
call flexviews.add_expr(@mvid, 'KEY', 'territory_lft', 'territory_lft_key');
call flexviews.add_expr(@mvid, 'KEY', 'territory_rght', 'territory_rght_key');
call flexviews.add_expr(@mvid, 'KEY', 'territory_id', 'territory_id_key');
call flexviews.add_expr(@mvid, 'KEY', 'region_id', 'region_id_key');
call flexviews.add_expr(@mvid, 'KEY', 'company_id', 'company_id_key');
call flexviews.add_expr(@mvid, 'KEY', '_id', 'place_id_key');
call flexviews.add_expr(@mvid, 'KEY', 'territory_type', 'territory_type_key');

call flexviews.enable(@mvid);

select * from mv_place where territory_lft_plus_one = territory_rght and territory_type = 'T';

select sleep(5);

call flexviews.refresh(flexviews.get_id('fst', 'mv_place'), 'BOTH', NULL);
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

2 participants