How to get list of issues of a repo using Github GraphQL.NET - github-graphql

According to the documentation, I used this code to build a query:
var query = new Query()
.Repository("some_repo", "MuziburRahman")
.Select(r => new
{
r.Name,
r.Description,
Issues = r.Issues(100, null, null, null, null, null, null).Select(i => i.Nodes).Select(i => new
{
i.Title,
i.Body,
}).ToList(),
});
But it shows error: An expression tree may not contain a call or invocation that uses optional arguments.
What is wrong here?

Seems like they added another parameter, so you have to add another null.
r.Issues(100, null, null, null, null, null, null, null)

Related

Prisma - ConnectorError

I'm trying to learn Prisma on my hobby project so I started with basics.
The first thing I tried was a simple GET request which should list all results in a table.
// Using "#prisma/client": "^3.8.1",
const position = await prisma.position.findMany();
It worked fine but obviously, I don't have any data so it return an empty array. If I try to add some items to the Position table I'm getting error (mentioned below). Same error I'm getting also from Prisma Studio so I wonder If I did something wrong or what can I do to fix it.
Prisma schema
model Position {
id Int #id #default(autoincrement())
name String #db.VarChar(255)
externalId String #db.VarChar(255)
benefits String #db.Text()
}
MySQL Schema
CREATE TABLE `Position` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`externalId` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`benefits` text COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Query:
await prisma.position.create({
data: {
name: 'Position Name',
externalId: '321',
benefits: 'My benefits',
},
});
Error:
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Server(ServerError { code: 1064, message: "target: referral.-.primary: vttablet: (errno 1064) (sqlstate 42000) (CallerID: unsecure_grpc_client): Sql: \"insert into Position(`name`, externalId,
benefits) values (:v1, :v2, :v3)\", BindVars: {}", state: "42000" })) })
at cb (C:\Develop\referral-nextjs-prisma\node_modules\#prisma\client\runtime\index.js:38695:17)
at async assetHandler (webpack-internal:///./pages/api/position/index.tsx:12:34)
at async Object.apiResolver (C:\Develop\referral-nextjs-prisma\node_modules\next\dist\server\api-utils.js:102:9)
at async DevServer.handleApiRequest (C:\Develop\referral-nextjs-prisma\node_modules\next\dist\server\base-server.js:1076:9)
at async Object.fn (C:\Develop\referral-nextjs-prisma\node_modules\next\dist\server\base-server.js:963:37)
at async Router.execute (C:\Develop\referral-nextjs-prisma\node_modules\next\dist\server\router.js:222:32)
at async DevServer.run (C:\Develop\referral-nextjs-prisma\node_modules\next\dist\server\base-server.js:1103:29)
at async DevServer.run (C:\Develop\referral-nextjs-prisma\node_modules\next\dist\server\dev\next-dev-server.js:444:20)
at async DevServer.handleRequest (C:\Develop\referral-nextjs-prisma\node_modules\next\dist\server\base-server.js:319:20) {
clientVersion: '3.8.1'
}

Error: ER_INVALID_JSON_TEXT: Invalid JSON text: "Invalid value." at position 1 in value for column '._data'. IN NODE JS

I want to insert JOSN data/object into mysql using stored procedure using node js. First of all I know there are some similar question out there but I tried them and but still didn't get the result.
This is the first time I am using stored procedure and node js, So I have table name test_data
test_data
CREATE TABLE `test_data` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NULL DEFAULT NULL,
`address` VARCHAR(255) NULL DEFAULT NULL,
`city` VARCHAR(255) NULL DEFAULT NULL,
PRIMARY KEY (`id`)
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
AUTO_INCREMENT=2
;
This is stored procedure insert_data:
insert_data
CREATE DEFINER=`root`#`localhost` PROCEDURE `insert_data`(
IN `_data` JSON
)
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
declare p_name varchar(255) default null;
declare p_address varchar(255) default null;
declare p_city varchar(255) default null;
set p_name= json_unquote(json_extract(_data, '$.name'));
set p_address= json_unquote(json_extract(_data, '$.address'));
set p_city= json_unquote(json_extract(_data, '$.city'));
insert into test_data(name, address, city) values(p_name, p_address, p_city);
END
here is my node js code :
const con = require('./db/connection');
const _data = {
"name": "Ironman",
"address": "ani#gamil.com",
"city": "bhilai"
}
const sql = "CALL insert_data('"+_data +"')"
con.query(sql, _data,(error, result) => {
if(error){
return console.log("There is error in the query: " + error)
}
console.log(result)
})
ERROR
There is error in the query: Error: ER_INVALID_JSON_TEXT: Invalid JSON text: "Invalid value." at position 1 in value for column '._data'.
please help me out here, what am i doing wrong ?
Thanks
It seems to me that you are not actually passing a JSON value?
const _data = {
"name": "Ironman",
"address": "ani#gamil.com",
"city": "bhilai"
};
The above is a Javascript object, not its JSON representation. So here
const sql = "CALL insert_data('"+_data +"')"
the actual value of sql will be "CALL insert_data('[object Object]')" which is in fact not valid. Try dumping sql to console to verify that this is indeed the case.
Try with:
const sql = "CALL insert_data('"+ JSON.stringify(_data) +"')"

SELECT Query fails because of restrictions or so it says [duplicate]

This question already has answers here:
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints
(26 answers)
Closed 5 years ago.
I'm running a query against a MySQL database, and its statement is simply
SELECT * FROM tableOperationsHistory;
However, it fails and I get this exception (I translated it into English):
Fail activating restrictions. One or more rows contain values that
violate non-null, unique or foreign-key restrictions.
This is the routine where the error happens:
Public Function RetrieveTable(ByVal command_text As String, Optional ByVal parameters As ParameterSet = Nothing) As DataTable
Dim dt As New DataTable, retry = False
Do
Using comm = conn.CreateCommand
comm.CommandText = command_text
If parameters IsNot Nothing Then
Dim par As DbParameter
For Each pair In parameters
par = comm.CreateParameter
par.ParameterName = pair.Key
par.Value = pair.Value
comm.Parameters.Add(par)
Next
End If
Dim rdr As DbDataReader
RequestConnection()
Try
rdr = comm.ExecuteReader
dt.Load(rdr)
retry = False
Catch ex As Exception
retry = ShouldRetry(ex) 'EXCEPTION IS CAUGHT HERE
End Try
DismissConnection()
End Using
Loop While retry
Return dt
End Function
And this is the table definition statement:
CREATE TABLE `tableOperationsHistory` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`numero` varchar(45) DEFAULT NULL,
`pasta_id` int(11) DEFAULT NULL,
`dataHoraInicioPrazo` datetime DEFAULT NULL,
`dataHoraFinalPrazo` datetime DEFAULT NULL,
`urgente` tinyint(4) DEFAULT NULL,
`setorOrigem_id` int(11) DEFAULT NULL,
`unidade_id` int(11) DEFAULT NULL,
`setor_id` int(11) DEFAULT NULL,
`usuario_id` int(11) DEFAULT NULL,
`modalidadeComunicacaoJudicial_id` int(11) DEFAULT NULL,
`modalidadeRepercussao_id` int(11) DEFAULT NULL,
`especieTarefa_id` int(11) DEFAULT NULL,
`postIt` varchar(255) DEFAULT NULL,
`teor_observacao` varchar(255) DEFAULT NULL,
`comunicacaoJudicial_id` int(11) DEFAULT NULL,
`tarefa_id` int(11) DEFAULT NULL,
`mensagens` text,
`criadoPor_id` int(11) DEFAULT NULL,
`criadoEm` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=92 DEFAULT CHARSET=latin1;
How can this happen in a SELECT statement? What should I do?
This great community helped me to realize that such an error can be caused by "a mismatch in column definition (e.g. size of char fields) between the database and the dataset", and pointed me to another thread: https://stackoverflow.com/a/7029713/3718031
Possible relation with this, too: Column longtext exceeds the MaxLength limit
In my case, there are columns with "TEXT" datatype and it seems that might be the problem.
I thank deeply to all those who commented in my question and helped me to learn this.
EDIT: Since this question was voted-to-close and my problem remained, I tried to investigate a little further and made another question, I hope that one is properly exposed.

Changing border colors in GAS (and *not* changing some)

Follow up to this question using Google Apps Script: Set border color & style in spreadsheet programmatically
The format is in this order: .setBorder( top, left, bottom, right, vertical, horizontal, color, style )
According to the documentation,
"true" turns on format
"false" turns off format
"null" leaves it unchanged
My problem: "null" is turning the format off!
I have a very simple script for testing purposes:
var right = "red";
var left = "blue";
range.setBorder( null, null, null, true, null, null, right, null );
range.setBorder( null, true, null, null, null, null, left, null );
Shouldn't this set the right border red and the left border blue?
The result is only the blue. If I omit the blue line, it'll result in the red.
It seems the only way to get 2+ colors in a single cell is to do .setBorder separately using "null". But "null" is working as "false" and turning off the previous border.
SpreadsheetApp.flush() should solve the problem:
range.setBorder( null, null, null, true, null, null, right, null );
SpreadsheetApp.flush();
range.setBorder( null, true, null, null, null, null, left, null );
I am just rephrasing the asked question with the above answer as the following script makes more sense to the first-timers:
var rightBorderOn = true;
var leftBorderOn =true;
var rightBorderColor = "red";
var leftBorderColor = "blue";
range.setBorder( null, null, null, rightBorderOn, null, null, rightBorderColor, null );
SpreadsheetApp.flush();
range.setBorder( null, leftBorderOn, null, null, null, null, leftBorderColor, null );
Hope this helps some!

comparing a varchar field to the number zero returns as if its a true match

i am looking for some work around on this problem and/or i need it to reply with an empty result or the boolean false.
using the sql statement on MySQL
`SELECT * FROM users WHERE verify = 0 LIMIT 1`
the code above returns the second row in the table.
Here is the table i used:
CREATE TABLE IF NOT EXISTS `users` (
`user_id` bigint(20) unsigned NOT NULL,
`username` varchar(30) NOT NULL,
`password` varchar(60) NOT NULL,
`email` varchar(30) NOT NULL,
`firstname` varchar(30) DEFAULT NULL,
`lastname` varchar(30) DEFAULT NULL,
`status` tinyint(1) NOT NULL DEFAULT '1',
`verify` varchar(32) NOT NULL,
`verified` bit(1) NOT NULL DEFAULT b'0'
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=latin1;
INSERT INTO `users` VALUES(1, 'admin', '$2y$10$id6rHN6Zy8XHmCkWlAMvGO8pr3K4OD1zfFAZMaVgoGXbezY8SXcT2', 'admin#admin.com', 'Firstname', 'Lastname', 1, '21232f297a57a5a743894a0e4a801fc3', b'1');
INSERT INTO `users` VALUES(36, 'client', '$2y$10$gdtPImQhYoCIiTpTs/veW.BXsWUz6Zcxb.TY6XXQNO6uf5Q7kx99.', 'client#client.com', 'client', 'client', 1, 'cf3873cdefaefa2cc2c4f1efbba23202', b'0');
--edit, sorry did not specify want i wanted
i don't want it to return anything or maybe how do i make it that it would return false or empty result.
right now, i am using a nasty workaround by modifying the zero result and making it a text "zero" before passing it to the sql query. works but, if there is something better way that you can suggest it would be much appreciated.
I'm not sure what you expect to happen. When you write:
where verify = 0
MySQL has a conundrum. verify is a character string and 0 is an integer. They are not comparable, so MySQL converts one to the other. In this case, it will convert verify to an integer value, getting 0, and they match.
If you want a string comparison, then use:
where verify = '0'
However, that returns the same result.
If you want it to compare to the character value of 0, then perhaps you want:
where verify = '\0'