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

Port BRSQL to rust-g #25

Merged
merged 35 commits into from May 14, 2020
Merged

Port BRSQL to rust-g #25

merged 35 commits into from May 14, 2020

Conversation

ghost
Copy link

@ghost ghost commented Apr 9, 2020

Ports https://github.com/steamp0rt/BRSQL as a rust-g module.

Code is horrible, please nitpick and tell me how shit it is (so I can learn from my mistakes)

src/sql.rs Outdated Show resolved Hide resolved
src/sql.rs Show resolved Hide resolved
src/sql.rs Outdated Show resolved Hide resolved
@ghost ghost changed the title [DNM] Ports BRSQL to rust-g Ports BRSQL to rust-g Apr 10, 2020
@ghost
Copy link
Author

ghost commented Apr 10, 2020

image

@ghost
Copy link
Author

ghost commented Apr 10, 2020

tested and working, kinda.

Half the time it'll have a weird error like {"data":"MySqlError { ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '\u000e' at line 1 }","status":"err"}, guessing this is related to the byond_fn weirdness

/world/New()
	world.log << rustg_sql_connect_pool("localhost", "3306", "root", "password", "rustgtest", "", "", "")
	world.log << rustg_sql_query_blocking("INSERT INTO testing (`number`, `binary`, `text`, `float`, `double`) VALUES (?, ?, ?, ?, ?)", json_encode(list(1, list(1, 128, 255), "blocking 1", 1.12, 1.13)))
	world.log << rustg_sql_query_blocking("INSERT INTO testing (`number`, `binary`, `text`, `float`, `double`) VALUES (:a, :z, :b, :c, :d)", json_encode(list(a = 2, b = "blocking 2", c = 2.12, d = 2.13, z = list(255, 128, 1))))
	var/job = rustg_sql_query_async("SELECT * FROM testing", "{}")
	world.log << job
	var/done = 0
	while(!done)
		var/x = rustg_sql_check_query(job)
		switch(x)
			if(RUSTG_JOB_NO_RESULTS_YET)
				sleep(5)
				continue
			if(RUSTG_JOB_NO_SUCH_JOB)
				world.log << "wtf job [job] not made?"
				break
			if(RUSTG_JOB_ERROR)
				world.log << "job [job] errored?"
			else
				world.log << x
				done = 1
				break
World opened on network port 1337.
{"status":"ok"}
{"affected":1,"rows":[],"status":"ok"}
{"affected":1,"rows":[],"status":"ok"}
0
{"affected":1,"rows":[[1,[1,128,255],"blocking 1",1.1200000047683716,1.13],[2,[255,128,1],"blocking 2",2.119999885559082,2.13],[1,[1,128,255],"blocking 1",1.1200000047683716,1.13],[2,[255,128,1],"blocking 2",2.119999885559082,2.13]],"status":"ok"}

@ghost
Copy link
Author

ghost commented Apr 10, 2020

Should be ready for review now.

src/sql.rs Show resolved Hide resolved
Copy link
Author

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: cache connections

@SpaceManiac SpaceManiac changed the title Ports BRSQL to rust-g Port BRSQL to rust-g May 13, 2020
SpaceManiac
SpaceManiac previously approved these changes May 14, 2020
@tgstation-server tgstation-server dismissed SpaceManiac’s stale review May 14, 2020 04:00

Out of date review

@SpaceManiac SpaceManiac merged commit 0d33d19 into tgstation:master May 14, 2020
@ghost ghost deleted the theyve-gone-into-plaid branch May 14, 2020 13:11
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.

3 participants