<commit_before>action
extractStubFunctions: isStub
	self runSQL do: [ :func | 
		| function resultType language namespace argnames argtypes owner |
		
		isStub ifTrue: [ owner := nil ] ifFalse: [owner := self database ].
		
		((func atName: #prorettypename) = 'trigger') 
			ifTrue: [  
				function := SqlTriggerFunction oid: (func atName: #oid) name: (func atName: #proname) owner: owner stub: isStub.
			] 
			ifFalse: [
				(func atName: #proisagg) 
					ifTrue: [ function := SqlAggregateFunction oid: (func atName: #oid) name: (func atName: #proname) owner: owner stub: isStub. ]
					ifFalse: [ function := SqlFunction oid: (func atName: #oid) name: (func atName: #proname) owner: owner stub: isStub ].
				argnames := func atName: #proargnames.
				"Arguments and types are only extracted if function is not stub"
				(isStub not and: [ argnames isNotNil ]) ifTrue: [  
					argtypes := ((func atName: #proargtypes) substrings: ' ') collect: [ :oid | oid asInteger ].

					1 to: (argnames size) do: [ :i | 
						| argtype |
						argtype := self database addUniqueObject: (self getAllDatatypes detect: [ :datatype | datatype oid = (argtypes at: i) ]).
						function addArgument: (SqlArgument name: (argnames at: i) datatype: argtype owner: function). 
					]			
				]
			].
		
		function code: (func atName: 'prosrc').
		
		language := (SqlLanguage oid: (func atName: #prolang) name: (func atName: #prolangname) owner: owner).
		function language: (self database addUniqueObject: language).
		
		namespace := (SqlNamespace oid: (func atName: #pronamespace) name: (func atName: #pronamespacename) owner: owner).
		function namespace: (self database addUniqueObject: namespace).
		
		resultType := SqlDatatype oid: (func atName: #prorettype) name: (func atName: #prorettypename)  owner: owner.
		function returnType: (self database addUniqueObject: resultType).
		

		self database addObject: function.
	].<commit_msg>Hack to be able to load models with functions having OUT parameters. To fix!<commit_after>action
extractStubFunctions: isStub
	self runSQL do: [ :func | 
		| function resultType language namespace argnames argtypes owner |
		
		isStub ifTrue: [ owner := nil ] ifFalse: [owner := self database ].
		
		((func atName: #prorettypename) = 'trigger') 
			ifTrue: [  
				function := SqlTriggerFunction oid: (func atName: #oid) name: (func atName: #proname) owner: owner stub: isStub.
			] 
			ifFalse: [
				(func atName: #proisagg) 
					ifTrue: [ function := SqlAggregateFunction oid: (func atName: #oid) name: (func atName: #proname) owner: owner stub: isStub. ]
					ifFalse: [ function := SqlFunction oid: (func atName: #oid) name: (func atName: #proname) owner: owner stub: isStub ].
				argnames := func atName: #proargnames.
				"Arguments and types are only extracted if function is not stub"
				(isStub not and: [ argnames isNotNil ]) ifTrue: [  
					argtypes := ((func atName: #proargtypes) substrings: ' ') collect: [ :oid | oid asInteger ].
					
					1 to: (argnames size) do: [ :i | 
						| argtype |
						argtype := self database addUniqueObject: (self getAllDatatypes detect: [ :datatype | datatype oid = (argtypes at: (i min: argtypes size)) ]). self flag: 'This is a HACK to bypass problem with OUT parameters.'.
						function addArgument: (SqlArgument name: (argnames at: i) datatype: argtype owner: function). 
					]			
				]
			].
		
		function code: (func atName: 'prosrc').
		
		language := (SqlLanguage oid: (func atName: #prolang) name: (func atName: #prolangname) owner: owner).
		function language: (self database addUniqueObject: language).
		
		namespace := (SqlNamespace oid: (func atName: #pronamespace) name: (func atName: #pronamespacename) owner: owner).
		function namespace: (self database addUniqueObject: namespace).
		
		resultType := SqlDatatype oid: (func atName: #prorettype) name: (func atName: #prorettypename)  owner: owner.
		function returnType: (self database addUniqueObject: resultType).
		

		self database addObject: function.
	].
{'fraction_non_alphanumeric': 0.11767638992769883, 'fraction_numerical': 0.0004986287708800798, 'mean_word_length': 3.7705112960761, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3026421', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1256, 'n_words': 426}