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

SELECT query does not print folders from recursive paths. #37

Open
fubarhouse opened this issue Dec 11, 2017 · 4 comments
Open

SELECT query does not print folders from recursive paths. #37

fubarhouse opened this issue Dec 11, 2017 · 4 comments

Comments

@fubarhouse
Copy link

A simple SELECT query should be able to identify the relative path of a file, which should include its folder name.

Example:

fsql "SELECT * from /Users/---/vagrant/jenkins"

prints:

`-rw-r--r--	5248	Dec  7 14:28:14	b874568	config.xml`

instead of:

-rw-r--r--	5248	Dec  7 14:28:14	b874568	jobs/1/config.xml
@kashav
Copy link
Owner

kashav commented Dec 12, 2017

@fubarhouse, thanks for the issue! I agree, relative path definitely makes more sense than just the filename (note that you can get the full path using the FULLPATH attribute modifier).

Kind of limited on time right now, so I'm marking this as help wanted (feel free to give it a go, if you'd like!), but will definitely try to get around to it in the coming weeks.

@fubarhouse
Copy link
Author

fubarhouse commented Dec 17, 2017

@kshvmdn I've got a one-liner which switches the name out for the path in the walk function.

I've no idea how you want to control this - always on vs optional on, flags etc.

But, for the argument of functionality, I would expect it to always provide the path, rather than the name.

func(path string, info os.FileInfo, result map[string]interface{}) {
	result["name"] = path
	results = append(results, result)

So, this one line makes it do what I would expect it to.

If you'd like this submitted as a PR let me know - but it is one line which might cause a difference in behaviour elsewhere for you.

image

@kashav
Copy link
Owner

kashav commented Dec 27, 2017

@fubarhouse, sorry for the late response – just got the chance to play around with this.

This solution works in the most basic case, but it breaks when using path-modifiers on the name attribute. I'm not sure how to resolve this just yet; I think we're going to have to play around with how names/paths are handled in the format step, maybe use filepath.Rel with the inputted path(s) to get each file's relative path.

Nevertheless, feel free to create the PR, I can merge it to an off-branch and then make changes there. Thanks for taking a look!

@fubarhouse
Copy link
Author

PR #38 has been created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants