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

Enable math functions in sqlite #1886

Merged
merged 1 commit into from
Jan 29, 2023
Merged

Conversation

rtldg
Copy link
Contributor

@rtldg rtldg commented Dec 18, 2022

I'd like to use POW in sqlite please... (and also have this in 1.11) (also I didn't test this but this this should:tm: work)

@peace-maker
Copy link
Member

Please report back once you had time to test this change!

@rtldg
Copy link
Contributor Author

rtldg commented Dec 20, 2022

Just now tested on Windows and it worked fine. The github actions should upload assets imo

@sirdigbot
Copy link
Contributor

You should be able to comment with the code for a short test plugin that just sets up a database and executes a select query with POW or whatever in it.
Probably better than just saying it works.

@rtldg
Copy link
Contributor Author

rtldg commented Dec 25, 2022

#include <sourcemod>

public void OnPluginStart()
{
	char error[256];
	Database db = SQL_DefConnect(error, sizeof(error));
	PrintToServer("%s", error);
	DBResultSet query = SQL_Query(db, "SELECT POW(5, 2);");
	query.FetchRow();
	PrintToServer("%f", query.FetchFloat(0));
}

(assumes your default db is setup to sqlite)

Copy link
Member

@peace-maker peace-maker left a comment

Choose a reason for hiding this comment

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

The math functions were added in sqlite 3.35.0 and appear useful. I'm not sure moving business logic into sqlite is a good idea and postgres seems like a better choice if you really want to. But why not have sin/tan in a query?

@psychonic psychonic removed the Needs Testing untested by author label Jan 29, 2023
@psychonic psychonic merged commit d57d7e7 into alliedmodders:master Jan 29, 2023
StarterX4 pushed a commit to StarterX4/sourcemod that referenced this pull request Aug 2, 2023
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.

4 participants