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

Add Support for Key Value Hash #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nHurD
Copy link

@nHurD nHurD commented Feb 13, 2019

This will add support for outputting change data in a key value hash rather than a series of arrays (see #71) and is enabled by setting the use-key-value-hash to 1.

Once enabled, the changes will be outputted as follows:

 {                                                                   
         "change": [                                                 
                 {                                                   
                         "kind": "insert",                           
                         "schema": "public",                         
                         "table": "table_with_pk",                   
                         "changes": {                                
                                 "a": 2,                             
                                 "b": 1,                             
                                 "c": 2,                             
                                 "d": 3,                             
                                 "e": 3.540,                         
                                 "f": 876.563,                       
                                 "g": 1.23,                          
                                 "h": "teste     ",                  
                                 "i": "testando",                    
                                 "j": "um texto longo",              
                                 "k": "001110010101010",             
                                 "l": "Sat Nov 02 17:30:52 2013",    
                                 "m": "02-04-2013",                  
                                 "n": true,                          
                                 "o": "{ \"a\": 123 }",              
                                 "p": "'Old' 'Parr'"                 
                         },                                          
                         "columntypes": {                            
                                 "a": "smallint",                    
                                 "b": "smallint",                    
                                 "c": "integer",                     
                                 "d": "bigint",                      
                                 "e": "numeric(5,3)",                
                                 "f": "real",                        
                                 "g": "double precision",            
                                 "h": "character(10)",               
                                 "i": "character varying(30)",       
                                 "j": "text",                        
                                 "k": "bit varying(20)",             
                                 "l": "timestamp without time zone", 
                                 "m": "date",                        
                                 "n": "boolean",                     
                                 "o": "json",                        
                                 "p": "tsvector"                     
                         }                                           
                 }          
         ]                                                           
 }                                 

This will add an additional configuration flag that, if enabled, will
output the changes in a hash map rather than a series of arrays. When
enabled, the output will look something like this:

```json
{
	"change": [
		{
			"kind": "insert",
			"schema": "public",
			"table": "table_with_pk",
			"changes": {
				"a": 18,
				"b": "Test Insert",
				"c": "2019-01-11 07:05:33.047587"
			},
			"columntypes": {
				"a": "integer",
				"b": "character varying(30)",
				"c": "timestamp without time zone"
			}
		}
	]
}
```
Add additional tests to ensure the new key value functionality works
as expected.
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.

None yet

1 participant