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

Aliased tables are not correctly referenced in convenience views. #9

Open
simon-brooke opened this issue Dec 28, 2019 · 0 comments
Open
Labels
bug Something isn't working

Comments

@simon-brooke
Copy link
Owner

We're seeing this:

------------------------------------------------------------------------
--	convenience view lv_animal of entity animal for lists, et cetera 
------------------------------------------------------------------------
CREATE VIEW lv_animal AS
SELECT holding.holding_identifier ||', '|| holding.name AS holding_expanded,
	animal.holding,
	animal.animal_identifier ||', '|| animal.name AS dam_expanded,
	animal.dam,
	animal.animal_identifier ||', '|| animal.name AS sire_expanded,
	animal.sire,
	animal.born,
	animal.animal_identifier,
	animal.name,
	gender.gender AS gender_expanded,
	animal.gender,
	species.species AS species_expanded,
	animal.species,
	breed.breed AS breed_expanded,
	animal.breed,
	animal.is_pedigree,
	pasture.name ||', '|| pasture.area AS pasture_expanded,
	animal.pasture,
	animal.id
FROM species, pasture, breed, gender, animal, holding
WHERE animal.holding = holding.id
	AND animal.dam = animal.id
	AND animal.sire = animal.id
	AND animal.gender = gender.gender
	AND animal.species = species.species
	AND animal.breed = breed.breed
	AND animal.pasture = pasture.id
;

Clearly, animal.animal_identifier ||', '|| animal.name AS dam_expanded should be dam.animal_identifier ||', '|| dam.name AS dam_expanded

@simon-brooke simon-brooke added the bug Something isn't working label Dec 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant