gsr
05/27/2024, 10:55 PMepipko
05/28/2024, 8:17 PMJarrad Baker
05/29/2024, 7:38 PMepipko
05/29/2024, 10:14 PM<cfset jsonData = deserializeJSON(httpResp.fileContent) />
<cfloop array="#jsonData#" index="x">
<cfset ....
<cfset ....
<cfset label_status = #x.label_status#>
</cfloop>
Sometimes one of the elements does not exist and I am getting this error: Element LABEL_STATUS is undefined in X.
How do I check if this element exist before I try to assign a value of it the variable?rodyon
05/29/2024, 10:25 PMrodyon
05/29/2024, 10:26 PMrodyon
05/29/2024, 11:03 PMgsr
05/30/2024, 11:35 AMgsr
05/30/2024, 11:36 AMaliaspooryorik
gsr
05/30/2024, 12:37 PMgsr
05/30/2024, 12:37 PMgsr
05/30/2024, 12:38 PMaliaspooryorik
gsr
05/30/2024, 12:41 PMRyan Albrecht
05/30/2024, 12:56 PMgsr
06/07/2024, 2:02 PM<https://graph.instagram.com/me/media?fields=id,username&access_token=>
if i use just me without media, i get username but with media, it returns me empty data responseBrent
06/24/2024, 1:27 AMapplication.dsn
variable working so I can reference it in my .cfc components, but just setting it in the Application.cfc in onApplicationStart()
did not seem to be enough. My understanding is that this lifecycle method should run when the app starts and run once until a timeout or the context/app is destroyed. (see documentation linked).
In order to get the variable application.dsn
to persist across requests so I could reference it in my handler/query code, I had to add an onRequestStart()
and recall onApplicationStart()
inside that to reinitialize the variables. Is this expected? My gut is telling me I have something set up wrong and I should not have to do this. Here is a link to all of the code and project setup and my commit I had to do to get the variable to persist. I'm dumping the application variable when OnApplicationStart()
is called and every time I refresh the page, it gets run and dumped. My understanding is that it should only be called once on the application start so I'm not understanding and missing something if anyone can help me out.
(click on the links for direct permalinks to the lines and code I'm talking about)Brent
06/26/2024, 2:23 AMBrent
06/27/2024, 3:16 PMqueryExecute
. I keep getting an error that there are more question marks in the SQL than parameters defined, but I've triple checked and I'm not providing or referencing more params than I am defining:
queryExecute(
sql: "INSERT INTO mytbl VALUES(:firstColVal, :secondColVal);",
params: {
firstColVal: {
value: 1,
type: "numeric"
},
secondColVal: {
value: 2,
type: "numeric"
}
},
options: {
datasource: application.dsn,
result: "local.insertResult"
}
);
Is my syntax wrong, or has anyone else run into this issue?epipko
06/27/2024, 5:41 PMBrent
06/27/2024, 11:45 PMlocal.record = queryExecute(
sql: "SELECT * from someTbl WHERE id = ?",
params: [ local.someId ],
options: { datasource: myDDN ]
);
expect(local.record.someCol[1]).toBe(someVal);
This is from a test I have setup and it passes and works. It gets a record from the db to assert that the record has an expected value in a specific field.
What is the [1]
syntax? Is the someCol
an array? i.e. it has a value at the 0th (okay, 1 in Lucee) position? Is that what executeQuery returns? Some structure where the columns/fields are an array and the first position holds the column's value?Brent
07/01/2024, 6:35 PMDao.query1()
and Dao.query2()
.
Both queries return different sets of rows and are long and complicated. What is the best way to merge the results into a new Query result to return? (Using Lucee v5)
I've looked at using .reduce() but my understanding is that doing that returns an array (I'm trying to avoid altering the data type from query to array if possible.Brent
07/02/2024, 1:35 AMAngela Jones
07/05/2024, 7:57 PMBrent
07/08/2024, 9:31 PM// statesProvinces.cfm
<select>
<optgroup label="states">
<cfloop array="#sortHelper(request.data.states, "shortName")#" index="shortName">
<option value="#shortName#">#shortName#</option>
</cfloop>
</optgroup>
<optgroup label="provinces">
<cfloop query="request.data.provinces">
<option value="#shortName#">#shortName#</option>
</cfloop>
</optgroup>
</select>
What was happening is the provinces shortName
in the dropdown was being shown as all the same value - to be exact, all were showing the (same) last value of shortName
in the states array looped over above it.
The query pulling the provinces and states was correct and had all the correct keys and values, so was pulling my hair asking why the short name was all the same for the povinces loop..
Come to find out it was a scoping issue and if I changed the province query loop to the following, everything worked as expected and the shortNames all showed correctly for the provinces in the select:
<cfloop query="request.data.provinces">
<option value="#request.data.provinces.shortName#">#request.data.provinces.shortName#</option>
</cfloop>
Apparently there was a scope issue, causing the shortName
variable to be stuck at the last value assigned in the array loop above the provinces query loop.
What was maddening was that I could not reproduce this bug locally with the same code that was deployed to our staging environment - why it only occurred in a staging environment is beyond my comprehension, but the query was not cached etc. as far as I could tell.
Anyways, is there a better way to write this so it's not as ugly or a more elegant way to handle the scoping issue here? (there are multiple areas that follow the same pattern elsewhere in the codebase).gsr
07/10/2024, 12:14 AMvar uploadedFiles = fileUpload(variables.tempPath, "images[]", "", "makeunique");
writedump(uploadedFiles);
// Check if it's a single file or multiple files
if (isStruct(uploadedFiles)) {
// Single file upload
arrayAppend(uploadedFilesArray, uploadedFiles);
} else if (isArray(uploadedFiles)) {
// Multiple file upload
uploadedFilesArray = uploadedFiles;
}
arrayEach(uploadedFilesArray, function(file) {
result = processFile(file, sDirectory, structform.isWatermarked, structform.tableName);
arrayAppend(results, result);
});
the processFile is basically a function which does some watermarking and insert into DB
but i am getting eror: Error: Error processing 0001.jpg: An exception occurred while calling the function each.
Nick
07/23/2024, 7:27 PMBrent
07/24/2024, 5:17 PMdump()
- where do the dumps go if you don't abort right after?
I can see dumps all the time as long as I add an abort;
immediately after the dump call (to check a variable etc.). But, if I don't add the abort, sometimes I can see the output somewhere in the browser, and sometimes not (checking devtools responses etc. to see if they output there, but I cant find them anywhere).
I've been adding output="console"
to my dumps to at least see them in the terminal, but just curious if there is somewhere I'm not looking in the browser or elsewhere where those lost dumps (without aborting right after) go. (Using Lucee v5)Brent
07/26/2024, 3:28 PMHelperComponent::helper method()
I assume this is a Singleton because I'm not calling new() to get an instance.
Is that fine or is there a convention to doing this that I might be unaware of?