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

PostgresqlMetadata Retrieve trigger throw exception #267

Open
wiryonolau opened this issue Dec 7, 2022 · 5 comments
Open

PostgresqlMetadata Retrieve trigger throw exception #267

wiryonolau opened this issue Dec 7, 2022 · 5 comments
Labels
Bug Something isn't working Help Wanted
Milestone

Comments

@wiryonolau
Copy link

wiryonolau commented Dec 7, 2022

Bug Report

Incorrect column parameters when retrieving trigger info in sql

Q A
Version(s) 2.15.1
PostgreSQL 10.21

Summary

Incorrect column parameters when retrieving trigger info in sql

Sql produce by PostgresqlMetadata loadTriggerData()

SELECT "trigger_name",
		"event_manipulation",
		"event_object_catalog",
		"event_object_schema",
		"event_object_table",
		"action_order",
		"action_condition",
		"action_statement",
		"action_orientation",
		"condition_timing" "action_timing",
		"condition_reference_old_table" "action_reference_old_table",
		"condition_reference_new_table" "action_reference_new_table",
		"created"
FROM "information_schema"."triggers" WHERE "trigger_schema" = 'public'

condition_timing should be the alias of action_timing
condition_reference_old_table should be the alias of action_reference_old_table
condition_reference_new_table should be the alias of action_reference_new_table

Current behavior

Exception Thrown

PDOException: SQLSTATE[42703]: Undefined column: 7 ERROR:  column "condition_timing" does not exist
LINE 1: ...ition", "action_statement", "action_orientation", "condition...

How to reproduce

$adapter = new Adapter([
            'driver'   => 'Pdo_Pgsql',
            'hostname' => 'localhost',
            'port'     => 5432,
            'username' => 'postgres',
            'password' => '888888',
            'database' => 'postgres'
 ]);

$metadata = Factory::createSourceFromAdapter($adapter);
$metadata->getTriggers();

Expected behavior

Should produce this sql

SELECT "trigger_name",
	"event_manipulation",
	"event_object_catalog",
	"event_object_schema",
	"event_object_table",
	"action_order",
	"action_condition",
	"action_statement",
	"action_orientation",
	"action_timing" "condition_timing",
	"action_reference_old_table" "condition_reference_old_table",
	"action_reference_new_table" "condition_reference_new_table",
	"created"
FROM "information_schema"."triggers"
WHERE "trigger_schema" = 'public'
@wiryonolau wiryonolau added the Bug Something isn't working label Dec 7, 2022
@Ocramius
Copy link
Member

Ocramius commented Dec 7, 2022

Ia this also applicable to previous versions?

@wiryonolau
Copy link
Author

wiryonolau commented Dec 7, 2022

Ia this also applicable to previous versions?

test on latest version 9 also not working, I don't think anybody use lower then 9

Run using docker

docker run --rm  -p 5432:5432  -e POSTGRES_PASSWORD=888888 postgres:9

I haven't check previous laminas-db version

@Ocramius
Copy link
Member

Ocramius commented Dec 7, 2022

Sorry, I mean lower versions of this library 😁

@wiryonolau
Copy link
Author

2.13
2.14
2.15
does not work return same exception

@Ocramius
Copy link
Member

Ocramius commented Dec 7, 2022

Thanks for verifying: was just trying to understand if this was a regression 👍

@Ocramius Ocramius added this to the 2.15.2 milestone Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Help Wanted
Projects
None yet
Development

No branches or pull requests

2 participants