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

When column_name is null, write an empty string to the database table #109

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bkowshik
Copy link

@bkowshik bkowshik commented Jan 5, 2025

Fixes: #89


Query before

This was the query before making the change.

INSERT INTO dot."configured_tests" (
	  "test_id",
    "test_activated" ,
		"project_id",
		"scenario_id" ,
		"priority",
		"description" ,
		"impact",
		"proposed_remediation" ,
		"entity_id",
		"test_type" ,
		"column_name" ,
		"test_parameters",
	  "last_updated_by",
	  "date_added",
	  "date_modified"
) VALUES(
	   uuid_generate_v3(uuid_ns_oid(), '123'), 
     {{Edit_Add_Test_Form.formData.test_activated}},
		'{{Edit_Add_Test_Form.formData.project_id}}',
		'{{Edit_Add_Test_Form.formData.scenario_id}}',
		 {{Edit_Add_Test_Form.formData.priority}},
		'{{Edit_Add_Test_Form.formData.description}}',
		'{{Edit_Add_Test_Form.formData.impact}}',
		'{{Edit_Add_Test_Form.formData.proposed_remediation}}',
		'{{Edit_Add_Test_Form.formData.entity_id}}',
	  '{{Edit_Add_Test_Form.formData.test_type}}',
	  '{{Edit_Add_Test_Form.formData.column_name}}',
		'{{Edit_Add_Test_Form.formData.form_test_parameters_string}}',
		'{{appsmith.user.name == null ? '' : appsmith.user.name == null  }}',
		 NOW(),
		 NOW()) ;

Query now

This is the query after making the change.

INSERT INTO dot."configured_tests" (
	  "test_id",
    "test_activated" ,
		"project_id",
		"scenario_id" ,
		"priority",
		"description" ,
		"impact",
		"proposed_remediation" ,
		"entity_id",
		"test_type" ,
		"column_name" ,
		"test_parameters",
	  "last_updated_by",
	  "date_added",
	  "date_modified"
) VALUES(
	   uuid_generate_v3(uuid_ns_oid(), '123'), 
     {{Edit_Add_Test_Form.formData.test_activated}},
		'{{Edit_Add_Test_Form.formData.project_id}}',
		'{{Edit_Add_Test_Form.formData.scenario_id}}',
		 {{Edit_Add_Test_Form.formData.priority}},
		'{{Edit_Add_Test_Form.formData.description}}',
		'{{Edit_Add_Test_Form.formData.impact}}',
		'{{Edit_Add_Test_Form.formData.proposed_remediation}}',
		'{{Edit_Add_Test_Form.formData.entity_id}}',
	  '{{Edit_Add_Test_Form.formData.test_type}}',
	  '{{Edit_Add_Test_Form.formData.column_name || ''}}', -- ***** Modified line *****
		'{{Edit_Add_Test_Form.formData.form_test_parameters_string}}',
		'{{appsmith.user.name == null ? '' : appsmith.user.name == null  }}',
		 NOW(),
		 NOW()) ;

@bkowshik
Copy link
Author

Finally, I got the right error message with reference to this ticket. Had a bunch of issues with the Add_Test query from a syntax point of view 😅

Error while adding test! ERROR: duplicate key value violates unique constraint "configured_tests_pkey" Detail: Key (test_id)=(c3a73e06-5c42-3fe0-8eb1-cd7e618171fd) already exists.

image

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

Successfully merging this pull request may close these issues.

column_name added as "null" when test modified
2 participants