Skip to content

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

Merged
ismaeltocruz merged 2 commits into
datakind:mainfrom
bkowshik:issue-89-null-column-name
Aug 18, 2026
Merged

ismaeltocruz merged 2 commits into
datakind:mainfrom
bkowshik:issue-89-null-column-name

Conversation

@bkowshik

@bkowshik bkowshik commented Jan 5, 2025 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor 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

@ismaeltocruz
ismaeltocruz merged commit 591e3cd into datakind:main Aug 18, 2026
1 check passed
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

4 participants